1
votes

NServiceBus is supported in .net6

According to the hosting docs and .net3.1 WebAPI-sample hosting can be done with

var host = Host.CreateDefaultBuilder()
    .UseNServiceBus(context =>
    {
        var endpointConfiguration = new EndpointConfiguration("Samples.ASPNETCore.Sender");
        var transport = endpointConfiguration.UseTransport<LearningTransport>();
        transport.Routing().RouteToEndpoint(
            assembly: typeof(MyMessage).Assembly,
            destination: "Samples.ASPNETCore.Endpoint");

        endpointConfiguration.SendOnly();

        return endpointConfiguration;
    })
    .ConfigureWebHostDefaults(c => c.UseStartup<Startup>())
    .Build();

Microsoft of course have a guide on how to migrate from 3.1 to 6

But my knowledge seem to fall short as I fail to convert and host NServiceBus correctly in .net6. Any suggestions would be much appreciated.

1
Also found that experienced developers use the classic 3.1 way of hosting as seen in Dennis van der Stelt's example - Pontus Ekengren
That's because I still need to update that demo! :-) - Dennis van der Stelt
I'm not really sure what you're asking? What problems are you running into? That sample is downloadable and you can run it and it just works? Here's another example of Jimmy Bogard who actually did update his sample to .NET 6 with NServiceBus: github.com/jbogard/presentations/blob/master/DistributedTracing/… - Dennis van der Stelt
By the way, I commented before actually looking. I'm also using the generic host in my demo, just not the Fluent API style. I separated the calls. But as a result of your comment, I'm immediately updating the demo ;-) - Dennis van der Stelt
Dennis strikes again, thanks! "Answer" and I will upvote and ✔ - Pontus Ekengren

1 Answers

2
votes

As you mentioned in the comments, I have a demo called EventualConsistencyDemo that belongs to this presentation.

I just updated the code and you can find the code for the website here and for a background (console) application here.

Also Jimmy Bogard updated his demos to .NET 6 and you can find the code here.