Messages Require Aggregate Information
About the Deprecation
Messages that are sent and received in Mosaic-based solutions contain now the additional aggregate_id
and aggregate_type
fields. Those fields are used to describe on the message level what entity is associated with that message. The aggregate ID field contains the unique identifier (e.g. database ID) of the entity and the aggregate type field contains the name of the entity (suggested to use kebab-case). For bulk operations, the aggregate_id field contains the value MULTIPLE_IDS
, and if there is no unique identifier (yet) the value UNDEFINED_ID
is used.
Having the aggregate ID and aggregate type directly (together with the existing message type) at the message root allows for a more unified approach to handle messages. Messages can be internally routed to the corresponding handlers or can use more granular message selection without the need to parse the payload.
The @axinom/mosaic-messages
package includes one MultiTenantMessagingSettings
object per service (e.g. ImageServiceMultiTenantMessagingSettings
). These objects already contained the messaging settings with e.g. the message type. The latest versions of the library also includes the appropriate aggregate type for each message.
The JSDoc definition of the fields includes a description about the aggregate ID value.
Migration Guide
To make your solution compatible with the new message structure, you need to update the message sending code to include the aggregate_id
and aggregate_type
fields.
If you’re using the @axinom/mosaic-message-bus
and @axinom/mosaic-messages
libraries in your solution, you can update to the latest version of the libraries. The updated types will guide you through the locations that need to be updated. The aggregate type is already part of the message setting. To find out what to use as the aggregate ID, please refer to the doc type of the settings object on the library.
You can use the media template PR as a reference for the changes needed.
To make the messages within the media template compatible, please refer to the changes made in this PR.
Deprecation Timeline
Please check the Planned Deprecations page for when the removal of the deprecated functionality is planned.