RabbitMQ
RabbitMQ is a robust messaging broker that operates using the Advanced Message Queueing Protocol (AMQP). While it's not a Java Message Service (JMS) provider, it supports the JMS API through its JMS topic exchange plugin and JMS client libraries. Martini Server Runtime will need these components to connect to a RabbitMQ broker.
Prerequisites
Before connecting to a RabbitMQ broker, ensure the following components are added:
-
RabbitMQ Topic Exchange Plugin: This plugin is included with RabbitMQ by default but may need enabling using the command:
1
rabbitmq-plugins enable rabbitmq_jms_topic_exchange
-
RabbitMQ Management Plugin: Used for Martini runtime to query the list of destination names.
-
RabbitMQ JMS Client Library v2.6.0: Contains RabbitMQ's implementation of the JMS API.
-
RabbitMQ Java Client Library v5.16.0: Dependency of the JMS client library required for Java applications to interact with RabbitMQ.
After downloading the required libraries, place them in <martini-home>/lib/ext/
.
Configuration
-
Modify the Configuration File: Locate
<martini-home>/conf/broker/rabbitmq.xml
and change theuri
property value toamqp://{username}:{password}@{broker-ip-address}:{port}
. -
Use the Configuration File: Open
<martini-home>/data/override.properties
and add or change the following property:1
jms.configuration-file=rabbitmq
-
Restart Martini: Restart your Martini instance for the configuration changes to take effect. Verify the connection status under the Connections tab using the RabbitMQ management plugin.
It is recommended to review RabbitMQ documentation regarding with compatibility of JMS client before attempting to do any integrations.
Martini runtime supports publishing and receiving JMS message however publishing and receiving AMQP formatted message requires special handling.
Defining AMQP Destinations
For Martini Server Runtime to interact with AMQP queues, destination strings must include specific parameters:
Parameter | Default Value | Description |
---|---|---|
amqp | false |
Set to true to indicate an AMQP destination. |
exchangeName | Default RabbitMQ Exchange | Name of the exchange where messages will be sent. Required for sending AMQP messages, optional for receiving. |
routingKey | Queue/Topic Destination | Name of the exchange where messages will be sent. Required for sending AMQP messages, optional for receiving. |
An example destination string for AMQP: queue://com.torocloud.Hello?amqp=true&exchangeName=NotADefaultExchange&routingKey=johndoe
Sending & Receiving Messages
AMQP Messages
Sending
To send messages to an AMQP queue, set the amqp
parameter to true
in the destination string.
Receiving
Configure JMS listener endpoints to listen to destinations with amqp
parameter set to true
.
JMS Messages
Queue
Sending
Ensure pre-existing destination queues are configured with classic
queue type, Durable
durability, and true
auto-delete.
Receiving
Receiving JMS messages will work out of the box.
Topic
Sending
No special configuration required.
Receiving
Receiving JMS messages from topics will work out of the box.
Tuning RabbitMQ
Before production deployment, note that RabbitMQ's JMS client does not fully implement the JMS API. Consider using ActiveMQ (Classic) or ActiveMQ Artemis for full JMS API compliance.
Network
Configure network settings for high client throughput.
Message Format
Optimize message size to decrease latency and increase throughput.
High Performance Erlang (HiPE)
Consider using HiPE for increased throughput.
Plugins
Review and disable unnecessary plugins to conserve resources.
Monitoring
Enable monitoring for issue detection and resolution.
Refer to RabbitMQ's production checklist for comprehensive guidance.