replay and retry in saga using Axon 4.2

hi Allard/Steven,

  • i’m using Axon 4.2, where i used MongoTokenStore to restrict replaying events when i restart my application containing saga.
  • but i need retry to be happened when i get runtime exception.
  • if i use MongoTokenStore retry is not happening.
  • i want retry to happen for runtime exceptions and i don’t want replaying all events when i restart my application.

below is my code snippet to store MongoTokenStore. can u suggest if any configuration is missed for retry to happen but not replay to happen.

public MongoTokenStore tokenStore(MongoClient client) {
    MongoTokenStore.Builder builder = new MongoTokenStore.Builder();
    builder.mongoTemplate(DefaultMongoTemplate.builder().mongoDatabase(client).build());
    builder.serializer(JacksonSerializer.defaultSerializer());
    return builder.build();
}

This is the token store created in my db.

<i>{
    "_id" : ObjectId("5ee9c93f34f5634e643c0e5a"),
    "processorName" : "TestManagementSagaProcessor",
    "segment" : 0,
    "owner" : "14XXX@XXXXXXXX",
    "timestamp" : NumberLong(1592381197632),
    "token" : { "$binary" : "eyJ0aW1lc3RhbXAiOjE1OTIzODA3NzQuNzE3MDAwMDAwLCJ0cmFja2VkRXZlbnRzIjp7IjAwZDJjY2E1LWM0ZGMtNDE3Mi04NGY3LWZjOTMzYWQ0MjgyYiI6MTU5MjM4MDc3NDY3OSwiMDdhODY3NGMtODU5ZC00NzliLThiMGUtMWZhYmQ0NzE1ZDQ3IjoxNTkyMzgwNzc0NzE3fX0=", "$type" : "00" },
    "tokenType" : "org.axonframework.extensions.mongo.eventsourcing.eventstore.MongoTrackingToken"
}</i>

Any suggestion may be helpful.

Thanks
Siddu

Hi Siddu,

If you want to forcefully fail event handling so that it’s retried, you’d be best off to configure Axon such to react like that on the specific exception at hand.
The way to achieve this is to define a ListenerInvocationErrorHandler which does not simply log the exception (assuming that’s what you are seeing right now), but throws it further.

You can do this by using the EventProcessingConfigurer#registerListenerInvocationErrorHandler method.

In there, you should provide it the PropagatingErrorHandler, which will ensure the exception is thrown further.
Then, it’s the TrackingEventProcessor’s task to retry.

Note though just always retrying does not necessarily resolve the problem, especially from the Saga.
It would be more ideal to react to the exception by catching it, and by further dispatching a compensating action (read: command) or schedule an action to be done later on (read: DeadlineManager and @DeadlineHandler).

Trusting this will help you further Siddu!

Cheers,
Steven

PS. It is important to note that this mailing list will be discontinued as specified in this thread.
The thread also specifies where to look further for help when it comes to Axon as soon as this mailing list is closed.