Search code examples
rebus

Publisher with no subscribers


Hypothetical scenario, publisher publishes message, no one's available to process it. What I've been able to figure out is that the message will black hole.

There is a SO post for a publisher with ONLY ONE subscriber, and the answer was to send a message rather than publish it. I get that. Rebus subscriber-publisher system. Process message only by single subscriber

What I'm more concerned about is what if by some freak accident I'm publishing stuff that's supposed to be processed by some subscribers but they're all down for some reason (bad publish? act of god? I don't know)


Solution

  • The cool thing is that, once a subscriber has subscribed, it doesn't matter if it crashes and stays down while messages are published, because the events will just queue up in the subscriber's input queue.

    You see, a publisher has a "subscription storage", which is where subscriptions are stored. It can be a database, a JSON file, or if the transport supports it (like e.g. RabbitMQ and Azure Service Bus) the subscription storage is built into the transport(*).

    This means that a publisher can publish any number of events while subscribers come and go, but as long as they do not unsubscribe, then will eventually receive all of the events.


    *) In the form of the ability to do proper publish/subscribe messaging.