Saga not started

Hello There

It’s my first post here and let me tell you: Great work. We are big fans of the Axon Framework and use it in production since we started building our system.
Recently we moved from MongoDB/RabbitMQ to AxonDB and AxonHub. (yes using it in production :). Though there are some weird exceptions from time to time but it works very well and stable.
We are currently using the developer edition and hope to move to the Enterprise edition as soon as we can afford it. (We are still a startup and the prices are a bit high for us now).

Now to the actual topic:

We have a micro-service architecture and ServiceA emits an event E that should start a Saga S in ServiceB. (Everything running in kubernetes) But the Saga does not start.
The saga is very simple and just uses an @Saga annotation. There is no SagaConfiguration or anything else.
The only kind of configuration we have is EventHandlingConfiguration::usingTrackingProcessors (multi-threaded which results in “Duplicated segment claim detected” in AxonHub but works anyway :), TokenStore based on MongoDB and the AxonHub configuration like in the docs.

The other sagas (excluding one or two “tracking” Sagas) require events that are emitted from the same service and they work.

The question is: Are we missing something when we have a setup where a Saga is dependent on a foreign event? Shouldn’t AxonHub take care of this?

Saga Code:

@Saga
public class WorkoutStatisticSaga {
    private final static Logger log = LoggerFactory.getLogger(WorkoutStatisticSaga.class);

    @Autowired
    private transient ProgramPortfolioQueryRepository programPortfolioQueryRepository;

    @Autowired
    private transient CommandGateway commandGateway;

    private String programPortfolioId;
    private String workoutId;

    @StartSaga
    @SagaEventHandler(associationProperty = "workoutLogId")
    public void on(WorkoutLogCreated event) {
        log.info("Received = {}", event);
        ...
    }

    @EndSaga
    @SagaEventHandler(associationProperty = "workoutLogId")
    public void on(WorkoutLogRemoved event) {

    }

    @EndSaga
    @SagaEventHandler(associationProperty = "workoutLogId")
    public void on(WorkoutLogFinished event) {
        commandGateway.send(new LogWorkout(programPortfolioId, event.getWorkoutLogId(), workoutId));
    }
}


Thanks for the help
And keep up the fantastic work!

All the best
Jose

Hi Jose,

thanks for the kind words.
Do beware that the developer edition, while formally allowed to be used in production, has some limitations that don’t make it reliable for production use. It doesn’t support clustering (required for HA) and has a storage limit. The basic version doesn’t have these limitations.

If I recall correctly, the Saga configuration isn’t included in EventHandlingConfiguration (yet). So if you need this Saga to be tracking, you’ll have to configure this explicitly.

Cheers,

Allard

Good Morning Allard

Thanks a lot for the quick response and the hints regarding the limitations. We will move to a more suitable version ASAP :slight_smile:

Sorry if I explained myself not clear enough:
The Saga itself should be a subscribing one. Weird is that it’s not started at all.
The only difference is that this Saga is triggered by events coming from another service. (which should be coming from AxoHub if I’ve understood correctly)

Thanks
Jose

After having setup a tiny test environment with AxonDB, AxonHub and two services. (Zero configuration). Service-A has an aggregate, EventA and CommandA. ServiceB has just a plain subscribing EventHandler and a subscribing Saga both triggered by EventA.

I come to the conclusion that subscribing Sagas/EventHandlers do not work with AxonHub. Am I right here?

I tried the following:

  • Just using the annotations @Saga and @EventHandler/@Component (on the class)
  • Using @Configuration with @ProcessingGroup and using EventHandlingConfiguration::registerSubscribingEventProcessor
  • Using @Configuration with @ProcessingGroup and using EventHandlingConfiguration::registerEventProcessor and using AsynchronousEventProcessingStrategy

Nothing worked.

Hi Jose,

That assumption is correct, AxonHub does not yet support other forms of Event Processors next to the TrackingEventProcessor.
So you’re inclined to use the TrackingEventProcessor in this format.
I do believe it is on the road map for AxonHub, although I am unable to tell you when it will be supplied.

Additionally, for your Sagas to be created/handling events from an outside Axon application, you can do two things:

  1. Make them Tracking, by building a SagaConfiguration for your Saga stating it should use tracking by calling the SagaConfiguration#trackingSagaManager(Class<?> sagaType) function.
  2. Publish the events over AMQP and introduce an AMQPMessageSource. Such a message source implements the SubscribableMessageSource interface, which is used internally in Axon to provide events to SubscribingEventProcessors.

Hope this helps you out!

Cheers,
Steven

Hi,

a slight nuance: AxonHub does support subscribing processors, but it uses the same semantics as the subscribing processors listening one the framework’s SimpleEventBus.

As Steven pointed out, in future releases of Axon Hub, we may provide an alternative means as well. Currently, distributing events is done through a Tracking Processor only.

Cheers,

Allard

Thank you Steven and Allard

Your answers helped us to clear this issue.
We will migrate to tracking processors then.