Sending Messages to RabbitMQ from a Production
InterSystems IRIS becomes a RabbitMQ publisher when an interoperability production includes a business operation that uses the RabbitMQ outbound adapter. This adapter allows the business operation to send messages to a RabbitMQ exchange. You have two options when using a production as a RabbitMQ publisher: use a built-in business operation that leverages the outbound adapter or build your own business operation that uses the adapter.
The RabbitMQ outbound adapter is the class EnsLib.RabbitMQ.OutboundAdapterOpens in a new tab. It includes the following settings, all of which appear in the Management Portal as settings for the business operation that uses the adapter:
MQHost defines the hostname or IP address for the RabbitMQ server.
MQPort defines the port number for communicating with RabbitMQ.
MQVirtualHost (optional) defines the virtual hostname for RabbitMQ.
Credentials defines the InterSystems credentials that correspond to the username and password of a Kafka client. For details on creating credentials, see Defining Reusable Items for Use in Settings.
For general information about building a custom business operation that uses an outbound adapter, see Defining Business Operations.
Both of the RabbitMQ adapters (inbound and outbound) accept additional settings which allow you to configure your production to connect with RabbitMQ using SSL/TLS. These settings also appear in the Management Portal as settings for the business service that uses the adapter.
For a detailed list of these settings, refer to the instructions for configuring a RabbitMQ client using the RabbitMQ API.
Send RabbitMQ Messages
The class of the messages sent by the outbound adapter to RabbitMQ is EnsLib.RabbitMQ.MessageOpens in a new tab. This class contains several properties for defining the message, including the following:
exchange defines the RabbitMQ exchange where the publisher is sending messages.
routingKey defines the routing key which the exchange will use to route the message.
deliveryMode defines whether the message will be treated as persistent (if the value is 2) or transient (if the value is 2).
contentEncoding defines the encoding of the message content (such as UTF-8).
encodedContent defines the content of the message, encoded as specified by contentEncoding.
For full descriptions of the message properties this message class makes available, refer to the RabbitMQ documentationOpens in a new tab.
The outbound adapter's SendMessage() method takes a EnsLib.RabbitMQ.MessageOpens in a new tab object as its sole argument, and sends that message to the RabbitMQ server. For example, a custom business operation could call the adapter’s method by including the following:
Built-in Business Operation
Rather than building a custom business operation that uses the outbound adapter, you can simply add EnsLib.RabbitMQ.OperationOpens in a new tab to the production and define the adapter properties using the Management Portal settings. This business operation calls the adapter's SendMessage() method when it receives a request from another business host in the production. This request should contain a RabbitMQ message of type EnsLib.RabbitMQ.MessageOpens in a new tab.
For basic information about adding a business operation to a production, see Adding Business Hosts.