...
Its very easy to enable ActiveMQ for AMQP. Just add a connector to the broker using the amqp URL.
Code Block |
<transportConnectors>
<transportConnector name="amqp" uri="amqp://0.0.0.0:5672"/>
</transportConnectors>
|
...
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:
Code Block |
|
|
<transportConnector name="amqp+nio" uri="amqp+nio://localhost:5672"/>
|
...
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:
Code Block |
|
|
<transportConnector name="amqp+ssl" uri="amqp+ssl://localhost:5671"/>
|
...
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.
Prefetch size and credit
When AMQP receiver connects to the broker, its mapped to the JMS consumer. This JMS consumer has to have appropriate prefetch size set. That prefetch size will be set from the receiving link credit if set or default value of 100 will be used. You can also tune a default value using prefetch transport attribute, like
Code Block |
<transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&wireFormat.maxFrameSize=104857600&transport.prefetch=10"/>
|
Note that the same value will be used for broker-side amqp receiver link that handles incoming messages.
Mapping to JMS
There are three basic conversion strategies that can be used with AMQP and interoperating with the JMS API.
...
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
Code Block |
|
|
<transportConnector name="amqp" uri="amqp://localhost:5672?transport.transformer=jms"/>
|
...
| 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 |
HTML Comment |
| char |
String |
| timestamp |
Long |
|
How AMQP messages bodies are mapped to JMS Messages:
...