Messages
This document provides information about the design, implementation, and intended usage of generic messaging in Axon Framework.
Design considerations
To allow components to communicate via messages, developers must represent those as Java objects. Axon Framework should provide means to construct such objects so it can use them to carry data from one component to another consistently across modules and deployment units. Below are the characteristics that every message has.
Implementation
In Axon Framework, a message is an immutable, serializable Java object implementing the Message
interface.
When the communication is bidirectional, the response is an object that implements ResultMessage
. A MessageDecorator
abstract object allows for building more complex messages by wrapping existing message types.
Usage
Avoid using generic messages directly. Use higher-level abstractions such as Command Messages, Query Messages, or Event Messages instead. |
Application developers don’t need to work directly with generic messages. The framework provides convenient higher-level abstractions for specific message types. It can also automatically construct the respective messages from domain-level objects, extract the payload of messages, and convert it to such domain-level objects.
That said, understanding the generic messaging design and object structure can significantly help during debugging or building custom extensions.