Message Body
For information about Jakarta Messaging body types, see Jakarta Messaging Message Bodies. For information about the structure of messages, see Jakarta Messaging Message Structure.
Import
When importing a Kafka message, the EMS server will first attempt to convert the message payload into a JSON format string. If successful, the Kafka message is translated into an EMS message with Jakarta Messaging body type TextMessage.
Otherwise, the Kafka message payload is processed as a stream of bytes and the Kafka message is translated into an EMS message with Jakarta Messaging body type BytesMessage.
EMS transports for Kafka can be configured to connect to a TIBCO Schema Repository deployment and obtain Apache Avro schemas for deserialization of imported Kafka message payloads.
If the EMS server is able to obtain the schema corresponding to the schema ID referenced in the imported message, it will attempt to deserialize the message payload into a JSON format string. If the deserialization is successful, the Kafka message is translated into an EMS message with Jakarta Messaging body type TextMessage.
If the imported Kafka message does not reference a schema ID, or if the deserialization process is unsuccessful, the EMS server defaults to the behavior outlined in the Default Translation section.
To enable this behavior, configure the schema_repository property in the transport definition.
schema_repository and finds a schema ID in the message payload, it always sets the JMS_TIBCO_IMPORTED_SCHEMA_ID property in the translated Jakarta Messaging message. This occurs regardless of whether a schema can be retrieved for that ID or the deserialization succeeds.Export
When exporting an EMS message to Kafka, the EMS message body is always translated into a JSON format string that serves as the Kafka message payload. This is the case regardless of the EMS message’s Jakarta Messaging body type.
For Jakarta Messaging body types whose contents cannot be directly mapped to JSON data types (BytesMessage, ObjectMessage, and StreamMessage), the message body is first converted to a base64-encoded stream of bytes. It is then used to create a JSON object consisting of a single key/value pair where the key is the message body type and the value is the base64-encoded byte stream.
For the Jakarta Messaging body types whose message fields consist of primitives and arrays of primitives that can be directly mapped to JSON data types (TextMessage and MapMessage), the conversion of the message body to JSON is straightforward, with each field and its value being added as a key/value pair to the JSON object.
byte and byte[] do not have JSON data type equivalents. When translating these fields, the values are base64-encoded and treated as strings.| Jakarta Messaging Body Type | Export Translation |
|---|---|
| MapMessage |
Kafka message with a JSON format string as payload. Each key/value pair in the JSON object corresponds to a field in the EMS message body. |
| BytesMessage |
Kafka message with a JSON format string as payload. The JSON object contains only a single key/value pair.
Key: Value: EMS message body as base64-encoded byte stream. |
| TextMessage |
Kafka message with a single key/value JSON format string payload. The JSON object contains only a single key/value pair.
Key: Value: String value of EMS message body. |
| Message | Kafka message with empty payload. |
| ObjectMessage |
Kafka message with a JSON format string payload. The JSON object contains only a single key/value pair. Key: Value: EMS message body as base64-encoded byte stream. |
| StreamMessage |
Kafka message with a JSON format string body. The JSON object contains only a single key/value pair. Key: Value: EMS message body as base64-encoded byte stream. |