Skip to content

Structure of a message

ID's

traceId

The trace id is a id, which will be used for one complete process.

As an example:

The Frontend makes a url request, which invokes a service function A. The service function A invokes a service function B. Service function A is returning a result back to the frontend. There is also a subscription C which listens for success responses of service A.

The traceId will be the same for all the messages and responses between the frontend, different service functions and subscriptions.

This allows to track the whole flow.

instanceId

The instance id is the unique id of the current event bridge (client) instance. This id is auto generated by default, but can be set as config parameter. This id might be used by some event bridge adapter. It can also be used for monitoring.

correlationId

The correlation id is a unique id that is used for a request (command) message and the corresponding response. While the traceId stays the same for a whole process flow, the correlationId is only valid and used for a single call.

id (message id)

Each message has a unique id, which might be used by the underlying event bridge/infrastructure or for persistence purposes.

principalId

The principal id is an optional field, which can be set by business logic to the user id. The principal id should be some technical user id and not something like an email, as it might be logged. It is recommended to use the message principal id for any authentication/authorization, because this way, there is no need to look into the message payload, which might be encrypted or not present.

The principal id is propagated down - like the trace id - in the whole process flow. So it will be available in subscriptions and function invocations. Each message has a unique id, which might be used by the underlying event bridge/infrastructure or for persistence purposes.

tenantId

The tenant id is an optional field, which can be set by business logic to the tenant id. The principal id should be some technical tenant id and not something like an company name, as it might be logged.

The tenant id is propagated down - like the principal id - in the whole process flow. So it will be available in subscriptions and function invocations. Each message has a unique id, which might be used by the underlying event bridge/infrastructure or for persistence purposes.

Message structure

As PURISTA is a message based framework, the structure of messages might be interesting.

fieldrequireddescription
messageTypeyesthe type of message eg. command, response, custom...
idyesthe unique id off a single message
timestampyesthe timestamp as number in ms when the message was created
correlationIdonly used in Command and CommandResponse messagesa unique id generated when a comman message is send. the command response is using same correlationId
principalIdnothe unique id of the user
tenantIdnothe unique id of the tenant
eventNamenoa string representing the business event name
senderyesthe service function or subscription who sends the message
sender.serviceNameyesthe service name
sender.serviceVersionyesthe service version
sender.serviceTargetyesthe service function or subscription name
sender.instanceIdyesthe unique id of the event bridge instance which sends the message
receiverdepends on message typethe service function or subscription who should receive the message
receiver.serviceNameonly for commands & responsesthe service name
receiver.serviceVersiononly for commands & responsesthe service version
receiver.serviceTargetonly for commands & responsesthe service function or subscription name
receiver.instanceIdonly for command responsesthe unique id of the event bridge instance which receives the message
payloaddepends on message typethe message payload (business data)
otpnoOpenTelemetry context propagation as json stringified string