@Slf4j@Aggregatepublic class Test2 {
@AggregateIdentifier String id;
@CommandHandler public Test2(CreateTest2Command command) { log.info("I was called"); apply(new Test2CreatedEvent(command.getId())); }
@EventSourcingHandler public void on(Test2CreatedEvent event) { id = event.getId(); }
}
@Saga@Slf4j@NoArgsConstructorpublic class TestSaga {
@Inject private CommandGateway gateway;
@StartSaga @SagaEventHandler(associationProperty = "id") public void on(TestCreatedEvent event) { log.info("saga started"); CreateTest2Command c = new CreateTest2Command(IdentifierFactory.getInstance().generateIdentifier()); log.info("send command: {}", ReflectionToStringBuilder.toString(c)); gateway.send(c); }
@SagaEventHandler(associationProperty = "id") public void on(Test2CreatedEvent event) { log.info("got event: {}", ReflectionToStringBuilder.toString(event));
end(); }}
--
You received this message because you are subscribed to the Google Groups "Axon Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to axonframewor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
gateway.send(c).whenComplete((result, exception) -> log.info("Result: {} {}", result, exception));
Result: 1d1738ca-9942-4036-928e-be0e3a735c5e null
gateway.send(new CreateTestCommand(IdentifierFactory.getInstance().generateIdentifier()));
@EnableAxon@Configurationpublic class AxonConfigs {
[...]
@Bean
@Bean public SagaStore<Object> sagaStore() { return new MongoSagaStore(new org.axonframework.mongo.eventhandling.saga.repository.DefaultMongoTemplate( mongoClient, database, sagaCollection)); }
gateway.send(c).whenComplete((result, exception) -> log.info("Result: {} {}", result, exception));
Result: 1d1738ca-9942-4036-928e-be0e3a735c5e null