Skip to main content

Message types

Every message exchanged through jEAP Messaging must conform to a well-defined type. Two kinds exist: Events and Commands. Both carry message info (identifier, type), the publisher, an optional list of references, and an optional payload. A custom type prescribes which references and which payload are required. All type definitions must be collected in the Message Type Registry.

DomainEvent base structure

The "Builder default" column refers to the AvroDomainEventBuilder / AvroCommandBuilder base classes, which fill these fields automatically.

FieldDescriptionMandatoryBuilder default
domainEventVersionSemver of the event structureY1.2.0
processIdId of a business processN
publisher.systemPublishing systemY
publisher.servicePublishing serviceY
type.nameType nameYunqualified message name
type.versionSemver of the typeY
type.variantDistinguishes events of the same type business-wiseN
identity.eventId (alias id)Unique event idYrandom UUID
identity.idempotenceIdMust carry the SAME value if the same event is re-published under at-least-once deliveryY
identity.createdUnix timestamp (ms, UTC)Ycurrent timestamp
user.id, familyName, givenName, businessPartnerName, businessPartnerId, propertiesMap (Map<String,String>)User infoN
referencesList of referencesN
payloadMessage payloadN

Command base structure

A Command has the same shape as a DomainEvent, except it uses commandVersion instead of domainEventVersion and its identity field is named id (there is no eventId alias). The "Builder default" column refers to the AvroCommandBuilder base class.

FieldDescriptionMandatoryBuilder default
commandVersionSemver of the command structureY1.2.0
processIdId of a business processN
publisher.systemPublishing systemY
publisher.servicePublishing serviceY
type.nameType nameYunqualified message name
type.versionSemver of the typeY
type.variantDistinguishes commands of the same type business-wiseN
identity.idUnique message idYrandom UUID
identity.idempotenceIdMust carry the SAME value if the same command is re-published under at-least-once deliveryY
identity.createdUnix timestamp (ms, UTC)Ycurrent timestamp
user.id, familyName, givenName, businessPartnerName, businessPartnerId, propertiesMap (Map<String,String>)User infoN
referencesList of referencesN
payloadMessage payloadN

References

Each reference must define a type (the business-object type it points to). Distinguish three things:

RoleType of referenceType of business object
Field name in the ...References record (e.g. old, new)The field's record type, ending in Reference (e.g. AhvReference)The type string field on the reference (e.g. "Person")
record DeclarationCreatedReferences {
DeclarationReference declaration;
}
record DeclarationReference {
string type = "Declaration";
string id;
int version;
}

Payload

The payload depends on the message pattern:

PatternPayload
Event NotificationNo payload, only references
Event-Carried State TransferPayload required
Event-SourcingPayload required
CommandsPayload often needed, sometimes references suffice

Guidelines

  • Events must be DomainEvent objects and commands must be Command objects.
  • By default prefer messages without payload — this reduces coupling, because only the receiver should know which data it needs.
  • Prefer two distinct message types over using a variant. Variants exist mainly to distinguish generic events within a reaction chain.