Var host = cfg.Host("localhost", "/", h => ) Ĭfg. I found this example here services.AddSingleton(provider => (cfg => I actually found the solution in a deleted answer with a down vote on this very question. I also had the same issue and poke's answer didn't work for me as I needed to use DI for IBus, IPublishEndpoint and ISendEndpointProvider. One final disclaimer though: I personally haven’t used MassTransit, so I don’t really know if this makes actual sense for the library. start/stop the bus with the web applicationĪ(bus.Start) Ī(bus.Stop) Sbc.ReceiveEndpoint(host, Configuration, e =>
![masstransit .net masstransit .net](https://miro.medium.com/max/3216/1*AcSPKVVoL7zglZhHzQJ08w.png)
The reason for this is that RabbitMQ has a complete routing framework built-in and MassTransit will leverage this when persisting your subscriptions.
![masstransit .net masstransit .net](https://miro.medium.com/max/828/1*TB5vs4kBkshBluAb0ZuN2g.png)
That’s especially true when using the publish/subscribe pattern. Var host = sbc.Host(new Uri("rabbitmq://localhost"), h => MassTransit supports MSMQ, RabbitMQ, and others, but I find that RabbitMQ is really the way to go. The method can take any dependency as an argument, so you can easily inject the service provider there: public void Configure(IApplicationBuilder app, IServiceProvider serviceProvider, IApplicationLifetime applicationLifetime) Then, in your bus configuration, you would call LoadFrom with the service provider: sbc.ReceiveEndpoint(host, Configuration, e =>Īs for where you should do this (also in order to have access to the service provider), I would suggest you to do it in your Startup’s Configure method. In the configure action, you need to register you consumers and sagas in order for MassTransit to resolve them properly later. Services.AddSingleton, InMemorySagaRepository>() you still need to register the consumers/sagas
![masstransit .net masstransit .net](https://blog.soat.fr/wp-content/uploads/2020/05/road-4598095_1920-1536x1023.jpg)
In Startup.ConfigureServices, you need to add MassTransit, just like you would add other services: services.AddMassTransit(c => But from looking at the pull request that introduced it and the current source, I think what you need to do is the following: Since the package isn’t officially released, there also isn’t any documentation on it yet. NET Standard, which still isn’t complete, so you should probably be a bit careful as there are likely going to be quite a few moving parts until the final release. Furthermore, the new package is part of a massive migration for. Note that the package is currently only available as a pre-release version and also requires a pre-release version of MassTransit. If you are using the container (which is the default with ASP.NET Core), then you will need the package for MassTransit.