ActiveMQ supports the AMQP 1.0 protocol which is an OASIS standard.
Available from ActiveMQ version 5.8 onwards.
Enabling the ActiveMQ Broker for AMQP
Its very easy to enable ActiveMQ for AMQP. Just add a connector to the broker using the amqp URL.
It is enabled in the default ActiveMQ server configuration.
For more help see Run Broker.
The AMQP implementation fully supports an ActiveMQ security mechanism. This means that the broker accepts plain SASL authentication. Also, the authorization policies will be applied when you try to access (read/write) certain destinations.
For additional security, you can use AMQP over SSL as described in the following section.
Enabling AMQP over NIO
For better scalability (and performance) you might want to run the AMQP protocol over the NIO transport. To do that just use amqp+nio transport prefix instead of amqp. For example, add the following transport configuration in your XML file:
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. All you have to do is use the amqp+ssl transport prefix instead of amqp. For example, add the following transport configuration in your XML file:
- 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. If an AMQP address is used without the prefix, it will be used as a Queue.
Mapping to JMS
There are three basic conversion strategies that can be used with AMQP and interoperating with the JMS API.
|native||Default Wraps the bytes of the AMQP message into a JMS BytesMessage and|
also maps the headers of the AMQP message to headers on the JMS message
|raw||Wraps the bytes of the AMQP message into a JMS BytesMessage|
|jms||Maps headers of the AMQP message to JMS message headers and maps the|
body of the AMQP message to JMS body
Set the transformer transport option on the transportConnector to the desired mapping strategy. For example, to interoperate with JMS at the payload level, set the transformer option to jms
How AMQP message headers are mapped to JMS Headers:
The following headers are mapped regardless of the transformer used:
| AMQP Message || JMS Message || Notes |
| || JMS_AMQP_NATIVE || Will be set to true if the transformer is 'native' or 'raw', false otherwise. |
| message-format || JMS_AMQP_MESSAGE_FORMAT || |
The following headers are mapped if the transformer is 'native' or 'jms':
| AMQP Message || JMS Message || Notes |
| header.durable || JMSDeliveryMode || javax.jms.Message.DEFAULT_DELIVERY_MODE if not set |
| header.priority || JMSPriority || javax.jms.Message.DEFAULT_PRIORITY if not set |
| header.ttl || JMSExpiration || javax.jms.Message.DEFAULT_TIME_TO_LIVE if not set |
| header.first-acquirer || JMS_AMQP_FirstAcquirer || |
| header.deliveryCount || JMSXDeliveryCount |
| delivery-annotations. || JMS_AMQP_DA_ || |
| message-annotations.x-opt-jms-type || JMSType || |
| message-annotations.x-opt-to-type || Type of the JMSDestination || Comma separated list of 'queue', 'topic', or 'temporary', defaults to queue if not set. |
| message-annotations.x-opt-reply-type || Type of the JMSReplyTo || Comma separated list of 'queue', 'topic', or 'temporary', defaults to queue if not set. |
| message-annotations. || JMS_AMQP_MA_ || |
| application-properties.JMSXGroupID || JMSXGroupID || |
| application-properties.JMSXGroupSequence || JMSXGroupSequence || |
| application-properties.JMSXUserID || JMSXUserID || |
| application-properties. || || |
| properties.message-id || JMSMessageID || Auto generated if not set |
| properties.user-id || JMSXUserID || properties.user-id is decoded as a UTF-8 String |
| properties.to || JMSDestination || The name of the JMSDestination |
| properties.subject || JMS_AMQP_Subject || |
| properties.reply-to || JMSReplyTo || The name of the JMSReplyTo |
| properties.correlation-id || JMSCorrelationID || |
| properties.content-type || JMS_AMQP_ContentType || |
| properties.content-encoding || JMS_AMQP_ContentEncoding || |
| properties.creation-time || JMSTimestamp || |
| properties.group-sequence || JMSXGroupSequence || |
| properties.reply-to-group-id|| JMS_AMQP_ReplyToGroupID || |
| footer. || JMS_AMQP_FT_ || |
AMQP property value types are converted as follows:
| AMQP Type || Java Type || Notes |
| bool || Boolean || |
| byte || Byte || |
| short || Short || |
| int || Integer || |
| long || Long || |
| ubyte || Byte or Short || Short is used if value > Byte.MAX_VALUE |
| ushort || Short or Integer || Integer is used if value > Short.MAX_VALUE |
| uint || Integer or Long || Long is used if value > Integer.MAX_VALUE |
| ulong || Long || |
| double || Double || |
| float || Float || |
| symbol || String || |
| binary || String || Hex encoding of the binary value |
How AMQP messages bodies are mapped to JMS Messages:
If the transformer is set to 'jms', the they type of JMS message will depend on the body type of the AMQP message.
| Body Type || JMS Message Type |
| null || Message |
| Data || BytesMessage |
| AmqpSequence || StreamMessage |
| AmqpValue holding a null || Message |
| AmqpValue holding a String || TextMessage |
| AmqpValue holding a binary || BytesMessage |
| AmqpValue holding a list || StreamMessage |
| AmqpValue || ObjectMessage |
AMQP 1.0 client library
You can use Apache Qpid Proton.