title | keywords | tags | permalink | ||
---|---|---|---|---|---|
AMQP 0.9.1 protocol binding |
binding, protocol, amqp, amqp091, rabbitmq |
|
connectivity-protocol-bindings-amqp091.html |
When messages are sent in Ditto Protocol (as UTF-8
encoded String payload),
the content-type
of AMQP 0.9.1 messages must be set to:
application/vnd.eclipse.ditto+json
If messages which are not in Ditto Protocol should be processed, a payload mapping must be configured for the AMQP 0.9.1 connection in order to transform the messages.
Supported AMQP 0.9.1 properties which are interpreted in a specific way are:
content-type
: for defining the Ditto Protocol content-typecorrelation-id
: for correlating request messages to responses
An AMQP 0.9.1 connection requires the protocol configuration source object to have an addresses
property with a list
of queue names.
{
"addresses": [
"<queue_name>",
"..."
]
}
An AMQP 0.9.1 connection requires the protocol configuration target object to have an address
property with a combined
value of the exchange_name
and routing_key
. It is continued with a list of topic strings, each representing a
subscription of a Ditto protocol topic.
{
"address": "<exchange_name>/<routing_key>",
"topics": [
"_/_/things/twin/events",
"_/_/things/live/messages"
]
}
There are no specific configuration properties available for this type of connection.
Ditto's Connectivity service is responsible for creating new and managing existing connections.
This can be done dynamically at runtime without the need to restart any microservice using a Ditto DevOps command.
Example connection configuration to create a new AMQP 0.9.1 connection (e.g. in order to connect to a RabbitMQ):
{
"connection": {
"id": "rabbit-example-connection-123",
"connectionType": "amqp-091",
"connectionStatus": "open",
"authorizationSubject": "<<<my-subject-id-included-in-policy-or-acl>>>",
"failoverEnabled": true,
"uri": "amqp://user:password@localhost:5672",
"sources": [
{
"addresses": [
"queueName"
]
}
],
"targets": [
{
"address": "exchangeName/routingKey",
"topics": [
"_/_/things/twin/events",
"_/_/things/live/messages"
]
}
]
}
}
Messages consumed via the AMQP 0.9.1 binding are treated similar to the WebSocket binding meaning that the messages are expected to be Ditto Protocol messages serialized as JSON (as shown for example in the protocol examples). If your payload is not conform to the Ditto Protocol, you can configure a custom payload mapping.