Generating Schema

When defining schema for a RabbitMQ action, card or node in the UI, an existing schema in the project can be selected or a new schema can be generated and automatically selected. When generating the schema, if the Message Header property is set to value None, adapter generates a simple classic schema with a single item to represent the message payload as raw binary data.

If the Message Header property is set to Version 1, the adapter generates JSON schema to represent the message metadata and payload.

The following example shows default Version 1 message JSON structure:
{
    "version": 0,
    "delivery_tag": 0,
    "redelivered": true,
    "exchange": "",
    "routing_key": "",
    "consumer_tag": "",
    "app_id": "",
    "content_type": "",
    "content_encoding": "",
    "correlation_id": "",
    "delivery_mode": 0,
    "reply_to": "",
    "expiration": "",
    "headers": {},
    "message_id": "",
    "priority": 0,
    "timestamp": "",
    "type": "",
    "user_id": "",
    "payload": ""
}

By default, the adapter includes all the fields in the generated JSON schema. A reduced set of fields to include in the schema can be specified using the Message Header Elements property. When the property is set the adapter includes only the elements specified in the comma-separated list of values set in the property. Refer to the Message Header Elements property description for more information.

The JSON type of the headers element can be array or object. When generating schema and consuming messages the selection for the type to use in the JSON generated by the adapter is made using the Native Headers Element Type property. For more information, see the Native Headers Element Type property description.

The JSON type of the payload element is string by default and captures the message payload in text format. It can also be any other JSON type if the message payload is JSON and the adapter is configured to capture the JSON structure. When generating schema and consuming messages the selection for the JSON type to use in the JSON generated by the adapter is made using the Message Payload Format property. For more information, see the Message Payload Format property description.

When generating schema, the adapter in certain cases needs to establish AMQP connection and retrieve a message from the specified queue, so that it can inspect the structure of the message and generated correct schema. In those cases, the adapter expects at least one message to be available on the queue. It proceeds to consume that message and then negatively acknowledges it so that it restored on the queue. Note that this results in the message technically being redelivered and will result in the broker setting the redelivered property on the message to true.

The following conditions are required for connecting to the broker and retrieving a message from the queue when generating a schema:
  • The Message Header is set to a value other than None. If set to None, the adapter generates a simple fixed schema with a single item to represent the message payload.
  • Schema generation is initiated while configuring a source action, card, or node. The Queue Name property must be set in that case. When configuring a target action, card or node, the default simple schema or JSON schema with all elements is generated depending on the Message Header value.
  • One or both of the following applies:
    • The JSON message structure is requested to have the headers element.
    • The Message Payload Format property is set to the value JSON. It is important to note that the headers element is implicitly requested when the Message Header Elements property is not set, in that case it is automatically included. It is explicitly requested when the Message Header Element property is set to a list of values including headers.
The following table provides a brief description about individual JSON elements in the JSON message structure.
Element JSON type Description
version number Version. Set the value 1 for the header version 1.
delivery_tag number Delivery tag, applicable when consuming messages.
redelivered boolean Redelivered flag, applicable when consuming messages.
exchange string Exchange name, applicable when consuming messages.
routing_key string Routing key, applicable when consuming messages.
consumer_tag string Consumer tag, applicable when consuming messages with a flow listener.
app_id string Application id. Custom value assigned by the user.
content_type string Message content type, such as gzip.
content_encoding string Message content encoding, such as text/plain.
correlation_id string Correlation id. Custom value assigned by the user.
delivery_mode number Delivery mode. Value 1 for transient, Delivery mode. Value 2 for persistent.
reply_to string Queue name for response messages.
expiration string Message expiration. To set string representation of a number representing expiration time in milliseconds.
headers object or array Native headers associated with the message. The type is controlled using the Native Headers Element Type property.
message_id string Message id. Custom value assigned by the user.
priority integer Message priority as assigned by the user.
timestamp string Message timestamp in yyyy-MM-dd HH:mm:ss format, in the current system locale's time zone.
type string Message type. Custom value assigned by the user.
user_id string User id. When set, checking is performed to ensure it matches the user id of the current connection.
payload string or JSON Message payload. The type is controlled by using the Message Payload Encoding property.