Domanda

In an event processing application I would like to record sequence numbers of all processed events for journaling purposes. These sequence numbers need to be unique, so upon restart the application needs to retrieve the highest number already used (the watermark) and ensure it assigns higher numbers to the new events.

The application uses LMAX Disruptor that already has the notion of sequence -- every publish into and read from the ring buffer is associated with a sequence number. However, that number is reset to 0 upon system restart. Is there a way to set the initial sequence number to a specific value before starting the disruptor?

An alternative solution would be to use the sequence-since-restart number provided by the disruptor and add to it the watermark read on startup, but that manipulation would have to be performed everywhere a global sequence number was needed, so I'd prefer if I could rely on the number held centrally by the disruptor.

È stato utile?

Soluzione

The RingBuffer has a resetTo() method that you should be able to call. Note that I've never tried this myself.

Altri suggerimenti

You need to initialise your sequence to your Journaled value.

Which is not readily exposed via the Dirsruptor dsl, so you would need to instantiate your own EventProcessors and provide your initialised sequence there.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top