rebus-org / Rebus.AzureServiceBus

:bus: Azure Service Bus transport for Rebus
https://mookid.dk/category/rebus
Other
33 stars 20 forks source link

Can a published message be used by multiple subscriptions simultaneously #67

Closed litiansky closed 3 years ago

litiansky commented 3 years ago

I'm new to queuing and I'm working on a project using ABP vnext. I have two applications A1 and A2. My requirement is that A1 and A2 have two-way communication, and A2 can subscribe to its own published events, so I set the publish and subscribe of both apps to the same "A1A2Queue". A1 needs to publish an event twice before A2 can receive it. How should I configure this?

mookid8000 commented 3 years ago

You should configure A1 and A2 each to have their own queue, e.g. a1-queue and a2-queue.

They can then both subscribe to the relevant event type by going

await bus.Subscribe<RelevantEvent>();

When that has been done, a TOPIC will have been created for the event RelevantEvent, and a SUBSCRIPTION beneath that topic will be configured to forward a copy to the queues a1-queue and a2-queue. This way, whenever any one of them goes

await bus.Publish(new RelevantEvent());

they will both receive a copy.

I hope that makes sense 🙂