question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding/Removing ReceiveEndpoints/Handlers/Consumers while Bus is started

See original GitHub issue

I would very much like to modify the set of ReceiveEndpoints and their Handlers and Consumers after the Bus has been started.

I have a set of components which start and stop at various times while my application is running. Some of these components need to wait for messages. The user is allowed to stop/start components.

As components come and go I would like them to be able to subscribe to the bus and then release their subscriptions when they stop.

I invision this would be something like .ReceiveEndpoint() on the IBus (or some interface of it). Which would return some sort of handle to the Endpoint, which I can later Dispose of to disconnect it. On this handle, I would also have Handler<> and Consumer<> methods which would let me modify the messages received and what happens to them. Likewise, the references from these should be disposable in some way.

I should note, I have been doing something similar to this for awhile with MT2. What I’ve done however is created new ServiceBus for each queue name that I want to listen on. These instances are created on demand, as a given component asks for it. I then am using HandlerSubscriptionExtensions.SubscribeHandler to get a subscription for a specific type. In MT2, this seems to result in the generation of the Exchanges. This method, and something like it, appears to be missing in MT3.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
phatboygcommented, Feb 23, 2017

You can call ConnectReceiveEndpoint on a host while the bus is running yes.

0reactions
slaneyrwcommented, Feb 23, 2017

Does this mean it’s done or is there another issue/pull request that is being used for this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Consumers
The Consume method returns a Task that is awaited by MassTransit. While the consumer method is executing, the message is unavailable to other...
Read more >
Common Mistakes
When creating a bus instance only to send or publish messages, it must be started. Failure to start the bus can lead to...
Read more >
Consumers
The bus itself, however, provides a temporary (auto-delete) queue which can be used to receive messages.
Read more >
Using MassTransit to manage message queues
We first need to tell MassTransit that we have a consumer with .AddConsumer<T>(); , then we need to register the queue with .ReceiveEndpoint( ......
Read more >
MT3 ConnectConsumer
I'm trying to add a consumer after the bus instance has been created. The reason being is that the consumer I create needs...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found