The Advanced Message Queuing Protocol (AMQP) is an open standard application layer protocol for Message Oriented Middleware. AMQP is often used with a Brokerthat relays messages between applications that cannot communicate directly.

Publisherssend AMQP messages to AMQP endpoints. Subscribers listen to AMQP endpoints for incoming messages. If a Brokeris involved it may persist messages so they can be delivered even if the subscriber is not online. Brokersmay 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 document defines two possible message mappings for the AMQP message body: the UADP message mapping defined in 7.2.2and a JSON message mapping defined in 7.2.2.6.4.7. AMQP Brokers have an upper limit on message size. The limit is defined by the AMQP field max-message-size. The mechanism for handling NetworkMessagesthat exceed the Brokerlimits depends on the MessageMapping. For MessageMappingsthat support chunking, the NetworkMessageshall be broken into multiple chunks. The chunk size plus the AMQP header should not exceed the AMQP max-message-size. For MessageMappingsthat do not support chunking, the NetworkMessagesexceeding the maximum size mut be skipped. Diagnostic information for such error scenarios are provided through the Eventsof the type PubSubTransportLimitsExceedEventTypedefined in 9.1.13.2and through the FailedTransmissionscounter of the PubSubDiagnosticsWriterGroupTypedefined in 9.1.11.9.

Security with AMQP is primary provided by a TLS connection between the Publisheror Subscriberand the AMQP Broker, however, this requires that the AMQP Brokerbe 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 NetworkMessagesand binary message encoding defined in 7.2.2.3. 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 Addressparameter defined in 6.2.7.3has the following form:

amqps://<domain name>[:<port>][/<path>]

The default port is 5671. The protocol prefix above provides transport security.

amqp://<domain name>[:<port>][/<path>]

The default port is 5672.

The syntax for an AMQP URL over Web Sockets has the following form:

wss://<domain name>[:<port>][/<path>]

The default port is 443.

Authentication shall be performed according to the configured AuthenticationProfileUriof the PubSubConnection, DataSetWriterGroup, DataSetWriteror DataSetReaderentities.

If no authentication information is provided in the form of ResourceUriand 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 WriterGroupand DataSetWriter.

The properties are defined through the KeyValuePairarray in the ConnectionProperties WriterGroupPropertiesand DataSetWriterProperties. The NamespaceIndexof the QualifiedNamein the KeyValuePairshall be 0 for AMQP standard properties. The Nameof the QualifiedNameis 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:

  • Connection;
  • session;
  • link.

The Valueof the KeyValuePairis converted to an AMQP data type using the rules defined in Table 165. 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 BrokerTransportQualityOfServicevalues as follows:

If the KeepAliveTimeis set on a WriterGroup, a value slightly higher than the configured value of the group should be used as AMQP idle time-out of the AMQP connection ensuring that the connection is disconnected if the keep alive message was not sent by any writer. Otherwise, if no KeepAliveTimeis specified, the implementation should set a reasonable default value.

When setting the maximum message sizes for the Link, the MaxNetworkMessageSizeof the PubSubGroupshall 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 on the capabilities of the device the Publisheror Subscriberis 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 which are called properties in the AMQP specification. Table 163describes how these fields shall be populated when an AMQP message is constructed.

Table 163– AMQP standard header fields

Field Name

Source

message-id

A globally unique value per message.

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 subclauses 7.3.4.8.1and 7.3.4.8.3.

The subjectdefines 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 WriterGroupor DataSetWriterthrough the KeyValuePairarray in the WriterGroupPropertiesand DataSetWriterProperties. The NamespaceIndexof the QualifiedNamein the KeyValuePairshall be 0 for AMQP standard message properties. The Nameof the QualifiedNameis constructed from a message prefix and the AMQP property name with the following syntax.

Name = message-<AMQP property name>

Table 164defines the AMQP standard message properties.

Table 164– OPC UA AMQP standard header QualifiedName Name mappings

AMQP standard property name

OPC UA DataType

AMQP data type

Note

to

String

*

user-id

ByteString

binary

reply-to

String

string

correlation-id

ByteString

*

absolute-expiry-time

Duration

timestamp

The absolute-expiry-time is calculated by adding the message-absolute-expiry-time (Duration) from the DataSetWriterPropertiesto the current time of the DataSetMessagecreation.

group-id

String

string

reply-to-group-id

String

string

creation-time

Boolean

timestamp

The creation-time is set to the current time of the DataSetMessagecreation if the message-creation-time (Boolean) in the DataSetWriterPropertiesis True, or else if the value is False or if the property is not configured, the AMQP property is not set.

content-encoding

String

symbol

Any name not in the table is assumed to be an application property. In this case the namespace provided as part of the QualifiedNameshall be the ApplicationUri.

The AMQP message header shall include additional promoted fields of the DataSetas a list of name-value pairs. DataSetfields with the PromotedFieldflag set in the FieldMetaData fieldFlagsare copied into the AMQP header. The FieldMetaData Structureis defined in 6.2.3.2.3. Promoted fields shall always be included in the header even if the DataSetMessagebody is a delta frame and the DataSetfield 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 165. If there is no rule defined for the data type, the field shall not be included.

Table 165– 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 = 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.

The message body is encoded in the AMQP bare-message application-data section as an AMQP ‘binary’ value.

A JSON body is encoded as defined for the JSON message mapping defined in 7.2.2.6.4.7.

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 Brokerlimits it shall be broken into multiple chunks as described in 7.2.2.4.4.

It is recommended to create the MetaDataQueueNameas described in 6.4.2.5.5by appending the text “$Metadata” to the related QueueName.