layout: default_md title: AMQP title-class: page-title-activemq5 type: activemq5

ActiveMQ supports the AMQP 1.0 protocol which is an OASIS standard.

Availability

Available from ActiveMQ version 5.8 onward.

Enabling the ActiveMQ Broker for AMQP

To enable AMQP protocol support on the broker add the following transport connector configuration referencing the amqp scheme in its URI:

<transportConnectors>
   <transportConnector name="amqp" uri="amqp://0.0.0.0:5672"/>
</transportConnectors>

It is enabled in the default ActiveMQ server configuration. For more help see Run Broker.

Security

The AMQP implementation fully supports an ActiveMQ security mechanism. This allows the broker to accept plain SASL authentication. Authorization policies are applied to a destination when it's accessed (read/write).

SSL

For additional security AMQP can be configured to run over SSL as described in the following section.

Enabling AMQP over NIO

For better scalability (and performance) the AMQP protocol should be configured to use NIO, rather than the default of TCP. To use NIO use the transport scheme amqp+nio instead of amqp.

Example:

<transportConnector name="amqp+nio" uri="amqp+nio://localhost:5672"/>

This transport uses the NIO transport underneath and will generally use much less threads than the standard connector. This connector can help if you want to use large number of queues

Enabling AMQP over SSL

It's easy to configure ActiveMQ to use AMQP over a SSL connection. To use SSL use the transport scheme amqp+ssl instead of amqp.

Example:

<transportConnector name="amqp+ssl" uri="amqp+ssl://localhost:5671"/>

For more details on using SSL with ActiveMQ, see the following article (How do I use SSL).

Working with Destinations with AMQP

You should prefix destination address with queue:// to use queue based destinations or topic:// to use topic based destinations. The destination type defaults to queue when the destination prefix is omitted.

Prefetch Size and Credit

When AMQP receiver connects to the broker it‘s mapped to the JMS consumer. This JMS consumer has to have appropriate prefetch size set. The broker will honor the credit set by the client or use the default value of 1000 if client doesn’t set it.

Example: tuning the default prefetch size:

<transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600&amp;transport.prefetch=10"/>

In this case, client preference will be ignored and the configured value will be used.

You can also tune broker-side amqp receiver link that handles incoming messages. It will use credit of 1000 messages by default, but you can override this by using producerCredit property, like 

<transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600&amp;transport.producerCredit=10000"/>

Mapping to JMS

There are three basic conversion strategies that can be used with AMQP and inter-operating with the JMS API.

StrategyDescription
native(Default) Wraps the bytes of the AMQP message into a JMS BytesMessage and maps the headers of the AMQP message to headers on the JMS message.
rawWraps the bytes of the AMQP message into a JMS BytesMessage.
jmsMaps headers of the AMQP message to JMS message headers and the body of the AMQP message to the JMS body.

Set the transformer transport option on the transportConnector to the desired mapping strategy. For example, to inter-operate with JMS at the payload level, set the transformer option to jms:

<transportConnector name="amqp" uri="amqp://localhost:5672?transport.transformer=jms"/>

How AMQP Message Headers are Mapped to JMS Headers

The following headers are mapped regardless of the transformer used:

AMQP MessageJMS MessageNotes
JMS_AMQP_NATIVEWill be set to true if the transformer is native or rawfalse otherwise.
message-formatJMS_AMQP_MESSAGE_FORMAT

The following header mappings apply when the transformer is either native or jms:

AMQP MessageJMS MessageNotes
application-properties.JMSXGroupIDJMSXGroupID
application-properties.JMSXGroupSequenceJMSXGroupSequence
application-properties.JMSXUserIDJMSXUserID
application-properties.**namename
delivery-annotations.**nameJMS_AMQP_DA_**name
footer.**nameJMS_AMQP_FT_**name
header.deliveryCountJMSXDeliveryCount
header.durableJMSDeliveryModejavax.jms.Message.DEFAULT_DELIVERY_MODE if not set.
header.first-acquirerJMS_AMQP_FirstAcquirer
header.priorityJMSPriorityjavax.jms.Message.DEFAULT_PRIORITY if not set.
header.ttlJMSExpirationjavax.jms.Message.DEFAULT_TIME_TO_LIVE if not set.
message-annotations.**nameJMS_AMQP_MA_**name
message-annotations.x-opt-jms-typeJMSType
message-annotations.x-opt-reply-typeType of the JMSReplyToComma separated list of queue, topic, or temporary. Defaults to queue if not set.
message-annotations.x-opt-to-typeType of the JMSDestinationComma separated list of queue, topic, or temporary. Defaults to queue if not set.
properties.content-encodingJMS_AMQP_ContentEncoding
properties.content-typeJMS_AMQP_ContentType
properties.correlation-idJMSCorrelationID
properties.creation-timeJMSTimestamp
properties.group-sequenceJMSXGroupSequence
properties.message-idJMSMessageIDAuto generated if not set.
properties.reply-toJMSReplyToThe name of the JMSReplyTo
properties.reply-to-group-idJMS_AMQP_ReplyToGroupID
properties.subjectJMS_AMQP_Subject
properties.toJMSDestinationThe name of the JMSDestination
properties.user-idJMSXUserIDproperties.user-id is decoded as a UTF-8 String.

AMQP property value types are converted as follows:

AMQP TypeJava TypeNotes
binaryStringHex encoding of the binary value
boolBoolean
byteByte
doubleDouble
floatFloat
intInteger
longLong
shortShort
symbolString
ubyteByte or ShortShort is used if: value > Byte.MAX_VALUE
uintInteger or LongLong is used if: value > Integer.MAX_VALUE
ulongLong
ushortShort or IntegerInteger is used if: value > Short.MAX_VALUE

How a AMQP Messages Body is Mapped to a JMS Message

If the transformer is set to jms then the JMS message type will depend on the body type of the AMQP message.

Body TypeJMS Message Type
AmqpSequenceStreamMessage
AmqpValueObjectMessage
AmqpValue holding a nullMessage
AmqpValue holding a StringTextMessage
AmqpValue holding a binaryBytesMessage
AmqpValue holding a listStreamMessage
DataBytesMessage
nullMessage

AMQP 1.0 client library

You can use Apache Qpid Proton.