Distributing events across different JVMs with Axon Server to Subscribing Event Processors (without Event Sourcing)
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Axon Server is a popular choice for handling distributed systems' event processing needs, especially in Java based applications using the Axon Framework. It manages both Command and Event routing, with effective scaling, and management of event streams without incorporating Event Sourcing. This discussion provides a deeper look at how Axon Server interacts with Subscribing Event Processors across different Java Virtual Machines (JVMs).
Understanding Axon Server with Subscribing Event Processors
Axon Server acts as an event store and message router. In scenarios where Event Sourcing is not used, Axon Server still manages the distribution of events to various subscribing processors. Subscribing Event Processors listen to events and act upon them. Unlike Tracking Event Processors, which maintain their own tracking tokens and can replay events, Subscribing Event Processors simply react to events as they occur in real-time.
Configuration and Setup
To configure Axon Server with Subscribing Event Processors, follow these necessary steps:
- Axon Server Setup: First, ensure Axon Server is up and running. It acts as the hub in the Axon architecture managing the distribution of events and commands.
- Service Configuration: Configure each microservice instance to connect to Axon Server. This typically involves specifying the Axon Server context in the
application.propertiesorapplication.ymlof the Spring Boot application:
- Define Event Handlers: In your microservices, define methods that will handle events. These methods are annotated with
@EventHandler, allowing Axon's event handling components to recognize and invoke them:
Event Handling and Distribution
When an event is published (e.g., a ProductCreatedEvent), it is sent to Axon Server, which then routes this event to all connected JVMs that have processors subscribing to this event type. The delivery mechanism ensures that if multiple instances of the same service are connected, each instance will receive the event only once.
Load Balancing and Fault Tolerance
Axon Server also provides load balancing of event distribution. If several instances of an application are connected to Axon Server, it distributes events in a manner that optimizes resource utilization across all instances.
In the event of a JVM failure, the robustness of Axon Server ensures continuous processing as long as other JVM instances are operational. This high availability setup helps in handling JVM or system failures gracefully.
Table: Summary of Subscribing Event Processors Configuration
| Aspect | Detail |
| Event Handling | Real-time, no replay, immediate consumption |
| Load Balancing | Automatic by Axon Server |
| Fault Tolerance | High, with other JVMs covering for failures |
| Setup Complexity | Moderate (depends on number of microservices and domain complexity) |
| Use Case | Best for real-time event handling where state consistency is managed independently |
Additional Considerations
- Scalability: Effectively scaling with subscribing processors requires a good understanding of the domain and appropriate segmentation of services.
- Event Versioning: As events evolve, managing versions becomes crucial to ensure compatibility across different service versions.
- Security and Authorization: Implementing security at the event level in Axon is critical, ensuring that only authorized services handle certain events.
Conclusion
Distributing events across different JVMs using Axon Server and Subscribing Event Processors provides a robust mechanism for handling real-time event-driven architectures. This setup is optimal when real-time handling and immediate event consumption are required, making it especially suited for applications that prioritize quick data processing and minimal latency without the need for event replay capabilities as offered by event sourcing.

