I am planning to develop a new application using CQRS, Java Springboot, AWS, and Axon. To implement the event bus, I intend to use Eventbridge and SQS. Eventbridge will help me easily implement the reply feature and route events to multiple services. Here is my current design:
I have created a custom extension for connecting to Eventbridge and SQS similar to AMQP extension. However, I have some concerns about compatibility with the Axon framework that I would like to address:
I have implemented an SQS adaptor using Subscribing Event Processors. SQS and Eventbridge do not support FIFO queues. I noticed that in the Query Service, the framework sends events to handlers as it receives them and does not handle the order of events. is there any way to force processors to call event handlers sequentially(like token stores in Streaming Event Processors) or should I implement it custom in my Query Service? To handle events sequentially, I think I can use the “axon-message-aggregate-seq” field in event metadata. One possible solution is to store the sequence number of the last event in the domain model in a DynamoDB. When a new event arrives, I will check if it is the correct one (i.e., last event + 1) and process it accordingly. If it is in the wrong order, such as last + 2, I will store it in the cache. After handling each event, I will check the cache and handle the events that should be handled.
In my Command Service, I have some REST APIs to send events on CommandGateway, and for the event store, I am using PostgreSQL. Currently, I am using a Simple Command Bus and running multiple instances of the Command Service behind a load balancer. While this implementation seems to work fine, I am unsure if it meets the requirements of the Axon framework. Should I use a distributed Command Bus like SpringCloud instead? What are the benefits of using distributed Command Bus in this case?