Communication and integration protocol

Applications developed with Devprime use an event-driven architecture (EDA) for asynchronous communication and use a standard protocol, ensuring fluid communication and integration between microservices. This approach ensures traceability and improves observability through logs and distributed tracing.

This documentation defines the payload model for publishing events to streaming systems such as RabbitMQ and Kafka, and details the adaptations required for legacy applications, highlighting the required and optional fields. For external applications, it is essential that the payload follows the same format and includes the specified information, ensuring compatibility and efficient monitoring. While native integration is optional, it is recommended to maximize the benefits of Devprime across the application ecosystem.

Event Default Payload Structure

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
{
  "Headers": {},
  "Id": "<Guid>", 
  "CorrelationId": "<Guid>",
  "TraceId": "<Guid>",
  "AppId": "<Guid fixo identificando app legado>",
  "AppName": "Myapp",
  "Version": 1,
  "Name": "OrderCreated",
  "CreationDate": "2022-06-07T11:26:21.7636769-03:00", 
  "Payload": {
    //Include your custom payload (json)
  }
}

Description of Fields

Field Type Description Obligation
Headers object Contains additional headers, can be used to carry specific metadata. Optional
Id string (GUID) Unique Guid identifier of the event generated by the legacy application when creating a new event. Required
CorrelationId string (GUID) Guid identifier used to correlate events and must be generated by the legacy application. Required
TraceId string (GUID) Tracking Guid identifier, useful for distributed tracing. Required
AppId string (GUID) Fixed Guid identifier of the legacy application that generates the event. Required
AppName string Name of the application that is publishing the event. Example: “Integrator 1.0”. Required
Version integer Event version. Usually incremented in case of changes in the payload format. Required
Name string Event name. Example: “OrderCreated”. Required
CreateDate string (DateTime) Date and time of creation of the event, in ISO 8601 format. Required
Payload object (JSON) JSON file containing the event data. Required

Examples of Use

This example includes all the fields required for complete traceability and proper integration with the observability system:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
{
  "Headers": {},
  "Id": "6598cd76-7e9f-4f1f-a140-01ed92f3b60d",
  "CorrelationId": "26a91e94-7f31-4401-8352-3d6d7ad0f5fb",
  "TraceId": "26a91e94-7f31-4401-8352-3d6d7ad0f5fb",
  "AppId": "e6ae2fd2-99ca-4287-bcaa-fb8c83b92edc",
  "AppName": "MyApp",
  "TenantID": "",
  "TenantUserID": "",
  "Version": 1,
  "Name": "OrderCreated",
  "CreationDate": "2024-09-11T12:04:47.5302497-03:00",
  "Payload": {
    "OrderId": "9375cde2-1770-4186-8ffb-ee6e81aa5d91",
    "CustomerName": "Name",
    "CustomerTaxId": "string",
    "Total": 0
  }
}

Reduced Payload (Optional)

This example omits some fields for a simpler implementation for cases where traceability is not required:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
{
  "AppId": "fef824a5-0eea-4b49-b08e-0bad25dbd55d",
  "AppName": "MyApp",
  "Version": 1,
  "Name": "OrderCreated",
  "CreationDate": "2022-06-07T11:26:21.7636769-03:00",
  "Payload": {
    "OrderId": "9375cde2-1770-4186-8ffb-ee6e81aa5d91",
    "CustomerName": "Name",
    "CustomerTaxId": "string",
    "Total": 0
  }
}

Final Thoughts

Implementing the payload pattern described above will allow legacy and external applications to interact effectively with the Devprime platform, ensuring that events are properly monitored and tracked throughout the homologation and production process. It is strongly recommended that developers follow the guidance to ensure compatibility and integration efficiency.

To learn more:

Last modified November 20, 2024 (61099f59)