Saga warranties - assynchonous

Consider the following use case:

My system must upload files. The uploading is started by an event on the eventbus (i.e. NewFileEvent), and should be performed assynchronously.
So i have a Saga has a #SagaEventHandler and @StartSaga on handle(NewFileEvent event).
Suppose my SagaManager is configured with a thread pool with 2 workers, and a JdbcSagaRepository.
While those two workers are busy (so there are 2 active Sagas), a third “NewFileEvent” is fired.
At this point, the application is stopped (before the 2 original workers were fininished uploading). Will the third saga be persisted by axon? Under which condition?

Hi,

if you process asynchronously, it all depends on the queue implementation that you use. If the queue is in-memory, you will lose data when you abruptly shutdown the application. When doing a clean shutdown, new events are blocked from being accepted, but Axon will attempt to finish processing of whatever is left in the queue.

If you’re on Axon 3, consider using a TrackingEventProcessor for asynchronous processing instead. It has better mechanisms to track progress and can guarantee it continues processing where it left off.

Cheers,

Allard

Hi,
I’am on Axon 2. I was using the AsyncSagaManager with its threadpool as a queue for queing Saga’s, but the ThreadPool is (of course) not persistent, so I must implement a simple ‘databased’ queue to ensure persistence.

Or dispatch your events on a message broker, such as RabbitMQ. That will also give you the persistence you need.