The Advanced Message Queuing Protocol (AMQP) is an open standard application layer protocol for Message Oriented Middleware. AMQP is often used with a Broker that relays messages between applications that cannot communicate directly.
Publishers send AMQP messages to AMQP endpoints. Subscribers listen to AMQP endpoints for incoming messages. If a Broker is involved it may persist messages so they can be delivered even if the subscriber is not online. Brokers may also allow messages to be sent to multiple Subscribers.
The AMQP protocol defines a binary encoding for all messages with a header and a body. The header allows applications to insert additional information as name-value pairs that are serialized using the AMQP binary encoding. The body is an opaque binary blob that can contain any data serialized using an encoding chosen by the application.
This specification defines two possible message mappings for the AMQP message body, the UADP message mapping defined in 7.2.2 and a JSON message mapping defined in 7.2.3. AMQP Brokers have an upper limit on message size. The mechanism for handling NetworkMessage that exceed the Broker limits depend on the encoding.
Security with AMQP is primary provided by a TLS connection between the Publisher or Subscriber and the AMQP Broker, however, this requires that the AMQP Broker be trusted. For that reason, it may be necessary to provide end-to-end security. Applications that require end-to-end security with AMQP need to use the UADP NetworkMessages and binary message encoding defined in 220.127.116.11. JSON encoded message bodies rely on the security mechanisms provided by AMQP and the AMQP Broker.
The syntax of the AMQP transporting protocol URL used in the Address parameter defined in 18.104.22.168 has the following form:
The default port is 5671.
The syntax for an AMQP URL over Web Sockets has the following form:
The default port is 443.
Authentication shall be performed according to the configured AuthenticationProfileUri of the PubSubConnection, DataSetWriterGroup, DataSetWriter or DataSetReader entities.
If no authentication information is provided in the form of ResourceUri and AuthenticationProfileUri, SASL Anonymous is implied.
If the authentication profile specifies SASL PLAIN authentication, a separate connection for each new Authentication setting is required.
AMQP allows sending properties as part of opening the connection, session establishment and link attach.
The connection properties apply to any connection, session or link created as part of the PubSubConnection, or subordinate configuration entities, such as WriterGroup and DataSetWriter.
The properties are defined through the KeyValuePair array in the ConnectionProperties WriterGroupProperties and DataSetWriterProperties. The NamespaceIndex of the QualifiedName in the KeyValuePair shall be 0 for AMQP standard properties. The Name of the QualifiedName is constructed from a prefix and the AMQP property name with the following syntax.
Name = <target prefix>-<AMQP property name>
The target prefix can have the following values
- link The Value of the KeyValuePair is converted to an AMQP data type using the rules defined in Table 98. If there is no rule defined for a data type, the property shall not be included.
The connection properties are intended to be used sparingly to optimize interoperability with existing broker endpoints.
A writer negotiates the delivery guarantees for its link using the snd-settle-mode settlement policy (settled, unsettled, mixed) it will use, and the desired rcv-settle-mode (first, second) of the broker.
Vice versa, the reader negotiates delivery guarantees using its rcv-settle-mode (first, second) and the desired snd-settle-mode (settled, unsettled) of the broker.
This matches to the BrokerTransportQualityOfService values as follows:
- AtMostOnce_1 – messages are pre-settled at the sender endpoint and not sent again. Messages may be lost in transit. This is the default setting.
- AtLeastOnce_2 – messages are received and settled at the receiver without waiting for the sender to settle.
- ExactlyOnce_3 – messages are received, the sender settles and then the receiver settles.
If the KeepAliveTime is set on a WriterGroup, a value slightly higher than the configured value of the group should be used as idle timeout of the connection ensuring that the connection is disconnected if the keep alive message was not sent by any writer. Otherwise, if no KeepAliveTime is specified, the implementation should set a reasonable default value.
When setting the maximum message sizes for the Link, the MaxNetworkMessageSize of the PubSubGroup shall be used. If this value is 0, the implementation chooses a reasonable maximum.
Other limits are up to the implementation and depend on the capabilities of the OS or or the capabilities of the device the Publisher or Subscriber is running on, and can be made configurable through configuration model extensions or by other means.
The AMQP message header has a number of standard fields. Table 96 describes how these fields shall be populated when an AMQP message is constructed.
Table 96 – AMQP Standard Header Fields
|message-id||A globally unique value created by the DataSetWriter.|
|subject||Valid values are ua-data or ua-metadata.|
|content-type||The MIME type for the message body.The MIME types are specified in the message body subsections 22.214.171.124.1 and 126.96.36.199.2.|
The subject defines the type of the message contained in the AMQP body. A value of “ua-data” specifies the body contains a UADP or JSON NetworkMessage. A value of “ua-metadata” specifies a body that contains a UA Binary or JSON encoded DataSetMetaData Message. The content-type specifies the whether the message is binary or JSON data.
The AMQP message header shall include additional fields defined on the WriterGroup or DataSetWriter through the KeyValuePair array in the WriterGroupProperties and DataSetWriterProperties. The NamespaceIndex of the QualifiedName in the KeyValuePair shall be 0 for AMQP standard message properties. The Name of the QualifiedName is constructed from a message prefix and the AMQP property name with the following syntax.
Name = message-<AMQP property name>
Table 97 defines the AMQP standard message properties.
Table 97 - OPC UA AMQP Standard Header QualifiedName Name mappings
|AMQP standard property name||OPC UA DataType||AMQP data type|
Any name not in the table is assumed to be an application property. In this case the namespace provided as part of the QualifiedName shall be the ApplicationUri.
The AMQP message header shall include additional promoted fields of the DataSet as list of name-value pairs. DataSet fields with the PromotedField flag set in the FieldMetaData fieldFlags are copied into the AMQP header. The FieldMetaData Structure is defined in 188.8.131.52.3. Promoted fields shall always be included in the header even if the DataSetMessage body is a delta frame and the DataSet field is not included in the delta frame. In this case the last known value is sent in the header.
When a field is added to the header it is converted to an AMQP data type using the rules defined in Table 98. If there is no rule defined for the data type, the field shall not be included.
Table 98 – OPC UA AMQP Header Field Conversion Rules
|OPC UA DataType||Conversion Rules to AMQP data types.|
|Boolean||AMQP ‘boolean’ type.|
|SByte||AMQP ‘byte’ type.|
|Byte||AMQP ‘ubyte’ type.|
|Int16||AMQP ‘short’ type.|
|UInt16||AMQP ‘ushort’ type.|
|Int32||AMQP ‘int’ type.|
|UInt32||AMQP ‘uint’ type.|
|Int64||AMQP ‘long’ type.|
|UInt64||AMQP ‘ulong’ type.|
|Float||AMQP ‘float’ type.|
|Double||AMQP ‘double’ type.|
|String||AMQP ‘string’ type.|
|ByteString||AMQP ‘binary’ type.|
|DateTime||AMQP ‘timestamp’ type.This conversion may result in loss of precision on some platforms.The rules for dealing with the loss of precision are described in OPC 10000-6.|
|Guid||AMQP ‘uuid’ type.|
|QualifiedName||The QualifiedName is encoded as an AMQP ‘string’ type with the format <NamespaceUri>’#’<Name>.|
|LocalizedText||Not supported and the related field is discarded.|
|NodeId||If the NamespaceIndex is = 0 the value is encoded as an AMQP ‘string’ type using the format for a NodeId defined in OPC 10000-6. If the NamespaceIndex > 0 the value is converted to an ExpandedNodeId with a NamespaceUri and is encoded as an AMQP ‘string’ type using the format for an ExpandedNodeId defined in OPC 10000-6.|
|ExpandedNodeId||If the NamespaceUri is not provided the rules for the NodeId are used.If the NamespaceUri is provided the value is encoded as an AMQP ‘string’ type using the format for an ExpandedNodeId defined in OPC 10000-6.|
|StatusCode||AMQP ‘uint’ type.|
|Variant||If the value has a supported datatype it uses that conversion; otherwise it is not supported and the related field is discarded.|
|Structure||Not supported and the related field is discarded.|
|Structure with option fields||Not supported and the related field is discarded.|
|Array||Not supported and the related field is discarded.|
|Union||Not supported and the related field is discarded.|
A JSON body is encoded as defined for the JSON message mapping defined in 7.2.3.
The corresponding MIME type is application/json.
A UADP body is encoded as defined for the UADP message mapping defined in 7.2.2.
The corresponding MIME type is application/opcua+uadp.
If the encoded AMQP message size exceeds the Broker limits it shall be broken into multiple chunks as described in 184.108.40.206.4.
It is recommended that the MetaDataQueueName as described in 220.127.116.11.6 is configured as a sub-topic of the related QueueName with the name $Metadata.