1

Using Rebus as message bus over RabbitMq message broker for enabling event driven communication between micro services. Using bus.Send(command) service A sends command over a specific queue, to which service B has subscribed. we are using type based routing.

Service B during the workflow of command needs to emit events for change in status (performingA, performedA etc..). One of the handler for an event will be in service B only ( per say it will listen to a specific event and call another api).

To achieve this do I need to have 3 instances of rebus in service B? One for subscribing to command from service A and another for raising events and 3rd to handle the event?

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Karan
  • 65
  • 5

1 Answers1

0

do I need to have 3 instances of rebus in service B? One for subscribing to command from service A and another for raising events and 3rd to handle the event?

No you only need one Rebus instance in service B.

One Rebus endpoint (with one input queue) is enough to:

...receive the command (you already know that )

...subscribe to an event (e.g. await bus.Subscribe<YourEvent>();)

...publish the event (e.g. await bus.Publish(new YourEvent(...);)

...receive the event (because you subscribed to it, creating a binding from a topic named after your YourEvent type to service B's input queue.

mookid8000
  • 18,258
  • 2
  • 39
  • 63
  • We want to avoid sharing types between the services so we used ISerializer in service B which pluck out body out of TransportMessage and cast it to an equivalent POCO ( thus circumventing type in message). However this means that whenever a message gets send or publish on the queue, service B will try to deserialize it into a specific type. This limits me from publishing and subscribing to an event on same bus. So i thought of 2 queues and thus 2 bus. As only 1 instance of IBus get registered with a container thus i need to have multiple container. Is this approach correct? Any suggestions? – Karan Aug 29 '18 at 06:39