How to void messages being lost during deployment of Publishers?

Hi,

I have publisher that has SQL Server persistence. It has a couple subscribers.
My deployment has the following basic steps:

  1. Deploy the publisher. The publisher starts.
  2. Restart the subscribers. The publisher receives the subscription messages.
  3. The publisher publishes events to the broker and the subscribers receive events and do their thing.

However there is a gap between step 1 and 2. After the publisher is started, it starts to process messages. Any events published before the subscribers are restarted will be lost because they are not registered as subscribers yet, right?

How can I prevent this from happening? If my understanding of how the publisher-subscriber work is incorrect, please let me know.

The way to guarantee that no events are missed by your subscribers is to make sure the subscriptions entries exists before the publisher is started.

You can achieve this by creating a SQL-script that you execute as part of deploying the publisher that inserts the relevant rows into the subscription table. (see https://docs.particular.net/persistence/sql/sqlserver-scripts#build-time-subscription-create-table for details on the table structure)

Does that make sense?

This only is happening for first time deployments. SQL persistance is a dubable subscriptiopn persister. As @andreasohlund mentions if this is an issue for first time deployment you will have to script the subscriptions.

After deployments subscriptions are not lost between restarts thus no events will be missed.

– Ramon