0
votes

I have Two independent Spring-Boot Micro-Service one is Command side Another is Query Side Where Command Service Store events in Mongodb and put Events in RabbitMQ then Query Side will Subscribe Queue and Build Query Modal.Now How To achieve Replay event And build Query modal in Axon?? is it possible where both service running independent on different-different node.if not possible then what should i follow to achieve that.

1

1 Answers

3
votes

If you choose to use RabbitMQ to distribute events you have to use Axon Subscribing Event Processors with SubscribableMessageSource as source - https://docs.axoniq.io/reference-guide/extensions/spring-amqp#reading-events-from-an-amqp-queue

Only Tracking Event Processor supports replaying of events - https://docs.axoniq.io/reference-guide/configuring-infrastructure-components/event-processing/event-processors#replaying-events

Consider using Axon Server or Kafka to distribute events. They support Tracking processors (and automatically Reply option as well).

You can find some examples here:

Axon Server: https://github.com/idugalic/digital-restaurant/blob/master/drestaurant-apps/drestaurant-microservices-rest-2/drestaurant-microservices-rest-2-query/src/main/kotlin/com/drestaurant/query/handler/RestaurantHandler.kt

Kafka: https://github.com/idugalic/digital-restaurant/blob/master/drestaurant-apps/drestaurant-microservices/drestaurant-microservices-query/src/main/kotlin/com/drestaurant/query/handler/RestaurantEventHandler.kt

...and yes, your Command side can be deployed independently of your Query side (projection). Query side can be re-created from scratch by replying all the events from the past. This will enable blue-green deployments (with projection DB schemas changing).

Best, Ivan