Skip to main content
InterSystems Supply Chain Orchestrator 2024.1
AskMe (beta)
Loading icon

Sending Messages to RabbitMQ from a Production

An InterSystems IRIS interoperability production can be a RabbitMQ publisher. You have two options: use a built-in business operation or build your own business operation that uses the RabbitMQ outbound adapter. There is also an API for use outside of a production.

Using the Business Operation

InterSystems provides a built-in business operation that can be used to publish messages to RabbitMQ without needing to write custom code. To use this business operation:

  1. Add EnsLib.RabbitMQ.OperationOpens in a new tab to your production. See Adding Business Hosts.

  2. Configure settings of this business host. See RabbitMQ Settings.

  3. Configure other business hosts to send EnsLib.RabbitMQ.MessageOpens in a new tab requests to this business operation.

When this business operation receives a message of type EnsLib.RabbitMQ.MessageOpens in a new tab, it publishes that message to RabbitMQ.

RabbitMQ Message Class

The EnsLib.RabbitMQ.MessageOpens in a new tab 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 in this class, refer to the RabbitMQ documentationOpens in a new tab.

Using the Adapter

If the built-in business operation does not meet your needs, you can directly use the RabbitMQ outbound adapter as follows:

  1. Create a custom business operation class:

    • The class should extend Ens.BusinessOperationOpens in a new tab.

    • The ADAPTER parameter should equal EnsLib.RabbitMQ.OutboundAdapterOpens in a new tab.

    • The class should define a message map:

      XData MessageMap
      {
      <MapItems>
        <MapItem MessageType="messageclass">
          <Method>methodname</Method>
        </MapItem>
        ...
      </MapItems>
      }
      
    • The class should define all the methods in the message map. These methods are known as message handlers. Each message handler should have the following signature:

      Method Sample(pReq As RequestClass, Output pResp As ResponseClass) As %Status {
      }

      The message handlers can call the instance methods of the adapter, which is accessible as the Adapter property of the business operation. The general syntax for calling these methods is as follows:

       do ..Adapter.MethodName(arguments)

      The RabbitMQ outbound adapter has one instance method, named SendMessage(), with the following signature:

      Method SendMessage(msg As EnsLib.RabbitMQ.Message) As %Status{
      }
  2. Add your business operation to your production. See Adding Business Hosts.

  3. Configure settings of this business host as described in RabbitMQ Settings.

  4. Configure other business hosts to send requests to this business operation.

See Also

FeedbackOpens in a new tab