ES+Saga+Quartz - Events being ignored by the EventStore

Hi,

I’m working with Axon 1.2 in a simple PoC including SAGA’s and Quartz.
The integration and the firing of events works just about fine. As you can see in the logs below, after the Scheduled job triggers all steps in handling the event get completed successfully.

The problem I’m experiencing is that when handling the event I want a change of state in an associated aggregate of the SAGA.
My aggregate apply()'s to a new event, it handles it correctly but the Event is never stored.

DEBUG - JobRunShell - Calling execute on job AxonFramework-Events.event-6060a1e0-fbf5-426b-b75b-0b262b51e040
DEBUG - FireEventJob - Starting job to publish a scheduled event
DEBUG - SimpleEventBus - Dispatching Event [IdentifiableScheduleEvent] to EventListener [AnnotationEventListenerAdapter]
DEBUG - ynchronousExecutionWrapper - Scheduling task of type [IdentifiableScheduleEvent] for full concurrent processing
DEBUG - SimpleEventBus - Dispatching Event [IdentifiableScheduleEvent] to EventListener [AnnotatedSagaManager]
DEBUG - SolicitudDeAmbulanciaSAGA - SAGA TIMED OUT - Token: Quartz Schedule token for job [event-6060a1e0-fbf5-426b-b75b-0b262b51e040] in group [AxonFramework-Events] ScheduledTime: 2011-11-14T09:26:10.034-03:00
DEBUG - Solicitud - Handling event ar.com.fluxit.osde.command.events.SolicitudChangedStateEvent@3dfabb76
DEBUG - AbstractUnitOfWork - Starting Unit Of Work.
DEBUG - AbstractUnitOfWork - Registering Unit Of Work as CurrentUnitOfWork
DEBUG - AbstractUnitOfWork - Committing Unit Of Work
DEBUG - DefaultUnitOfWork - Notifying listeners of commit request
DEBUG - DefaultUnitOfWork - Listeners successfully notified
DEBUG - DefaultUnitOfWork - Persisting changes to aggregates
DEBUG - DefaultUnitOfWork - Aggregates successfully persisted
DEBUG - AbstractUnitOfWork - This Unit Of Work is not nested. Finalizing commit…
DEBUG - DefaultUnitOfWork - Publishing events to the event bus
DEBUG - DefaultUnitOfWork - All events successfully published.
DEBUG - DefaultUnitOfWork - Notifying listeners after commit
DEBUG - AbstractUnitOfWork - Stopping Unit Of Work
DEBUG - DefaultUnitOfWork - Notifying listeners of cleanup
DEBUG - DefaultUnitOfWork - Listeners successfully notified
DEBUG - AbstractUnitOfWork - Clearing resources of this Unit Of Work.
INFO - FireEventJob - Job successfully executed. Scheduled Event has been published.

Find here the key pieces of code of my application

SolicitudDeAmbulanciaSAGA

private Solicitud solicitud;


@SagaEventHandler(associationProperty = “solicitudID”)
public void handle(IdentifiableScheduleEvent event) {
LOG.debug("SAGA TIMED OUT - Token: " + this.getScheduleToken() + " ScheduledTime: " + event.getScheduledTime());
if (this.isActive()) {
getSolicitud().anularPorTimeOut();

Solicitud

public void anularPorTimeOut() {
apply(new SolicitudChangedStateEvent()…

@EventHandler
protected void handle(SolicitudChangedStateEvent event) {
LOG.debug("Handling event " + event);
this.setState(event.getNewState());
}

I apologize for the lengthy email, I’m publishing this problem in the group as a last resource.
I think there’s nothing strange in the example, so my next steps will be to debug and check if the SAGA can keep an Aggregate instance as part of its state.

Thank you in advance,
Fer.-

I’ve found the answer to my concern here: https://groups.google.com/forum/#!searchin/axonframework/No$20UnitOfWork$20is$20currently$20started$20for$20this$20thread./axonframework/GJScxIl4Cq4/EmNI0BqIkhEJ

Where Allard clarifies the design debt I was exposing in my SAGA implementation.

Cheers!

Hi Fer,

I’m glad you already found the solution to the problem. The issue is a bit that the EntityManager (are you using Spring?) silently fails when adding entities without a backing transaction. It will only emit errors after an explicit flush().

Anyway, your problem should be solved once you send commands from your Saga.

Cheers,

Allard

Thanks Allard for your early response. That’s right, I’m using Spring and couldn’t spot any errors in the logs, thanks for clarifying the reason why.

I’ve quickly setup my Saga with the command bus and I’m using it to dispatch the change in state in my aggregate.
It took me just one additional class and gained tons in decoupling so I can see the benefit from that point of view :slight_smile:

Kind regards and congrats on Axon!