eventuate-tram / eventuate-tram-sagas

Sagas for microservices
Other
1k stars 228 forks source link

Retry execution of command handler instead of triggering compensation #80

Open ghost opened 2 years ago

ghost commented 2 years ago

Hi,

how can we retry the execution of a command handler method in case of failure instead of triggering the compensation logic immediately?

public CommandHandlers commandHandlerDefinitions() {
  return SagaCommandHandlersBuilder.fromChannel("CHANNEL_NAME")
      .onMessage(Command.class, this::handleCommand)
      .build();
}

public Message handleCommand(final CommandMessage<Command> command) {
  try {

    //logic
    return withSuccess();
} catch (Exception e) {

   // in case of failure, I want to retry the method instead of directly triggering the compensations action
   return withFailure(SagaError.of(e));
}
StefanMessner commented 1 year ago

Is there any update on this issue? Would be a realy valuable feature.