MongoSagaStore - Persisting and retrieving SagaManager attribute


I am having problem in using MongoSagaStore. I have a saga implementation like following. After setting the value for item attribute in one event handler and later when I try to get the value in another event handler the value is null.

I don’t face this problem when using JpaSagaStore.

@Saga(sagaStore = “mongoSagaStore”)
public class OrderManagementSaga implements Serializable {

private static final long serialVersionUID = 4573830325124783880L;

private transient CommandGateway commandGateway;

private String item;

@SagaEventHandler(associationProperty = “orderId”)
public void handle(OrderCreatedEvent orderCreatedEvent){
String paymentId = UUID.randomUUID().toString();
System.out.println(“Saga invoked”);
item = orderCreatedEvent.itemType;

//associate Saga
SagaLifecycle.associateWith(“paymentId”, paymentId);

System.out.println(“order id” + orderCreatedEvent.orderId);

//send the commands
commandGateway.send(new CreateInvoiceCommand(paymentId, orderCreatedEvent.orderId));

@SagaEventHandler(associationProperty = “paymentId”)
public void handle(InvoiceCreatedEvent invoiceCreatedEvent){
String shippingId = UUID.randomUUID().toString();

System.out.println("Saga continued with " + item);

//associate Saga with shipping
SagaLifecycle.associateWith(“shipping”, shippingId);

//send the create shipping command
commandGateway.send(new CreateShippingCommand(shippingId, invoiceCreatedEvent.orderId, invoiceCreatedEvent.paymentId));

The following is my MongoSagaStore configuration

public class SagaServiceConfiguration {

public org.axonframework.extensions.mongo.MongoTemplate axonMongoTemplate( mongoTemplate) {
return DefaultMongoTemplate.builder()


public TokenStore mongoTokenStore(org.axonframework.extensions.mongo.MongoTemplate axonMongoTemplate) {
return MongoTokenStore.builder().mongoTemplate(axonMongoTemplate).serializer(JacksonSerializer.defaultSerializer()).build();

public MongoSagaStore mongoSagaStore(org.axonframework.extensions.mongo.MongoTemplate axonMongoTemplate) {
return MongoSagaStore.builder()


Wong Liong Hung

Hi Wong,

we had the exact same problem when using the Jackson serialiser - it expects a getter for properties, otherwise they won't get persisted. There are other ways to indicate that a field should be serialised (such as adding a @JsonProperty annotation to it), but I think that's the reason for the behaviour you're seeing.

Regards, Levi