These days I investigated axon a lot, I found it is really great framework, to implement ES pattern. And I am preparing to use it for our product. But I still have some problems.
Now I have a spring cloud micro service, order service and ticket service, using axon.order aggregate handle order related event, ticket aggregate in ticket service handler the preserve, supply and shipment.
I have a saga class,
OrderManagementSaga in order service, to process the ordering. It will create/pay order and dispatch command about ticket supply change, shipment.
My question is how should I design the event(between aggregate and saga) and queue(for 2 services)?
For example, the business process is as below:
- order service gets an OrderPayCommand, handled by aggregate, apply an OrderPaidEvent
- Order aggregate handled this event, update order status, and publish it into AMQP(but the published event is not used.).
- OrderManagementSaga handle this event, dispatch a OrderTicketPreserveCommand.
- ticket service gets this command, apply an OrderTicketPreservedEvent, and handled in aggregate.
- ticket service publish the OrderTicketPreservedEvent into AMQP.
- order service gets this event, trigger saga to process next step.
I want to know what’s the best practice to design the:
- events: some events need to be handled in 2 service, like
OrderTicketPreservedEvent, it will handled by ticket service and order saga. Should I use different event for this?
- queues: I use topic type of AMQP, event in a queue processed by only one service. If I use same event, should I send it to TWO queues?