Sending Messages to JMS from a Production
An InterSystems IRIS interoperability production can be a JMS producer. You have two options: use a built-in business operation that leverages the outbound adapter or build your own business operation that uses the JMS outbound adapter. There is also an API for use outside of a production.
This page refers to classes in the EnsLib.JMSPEX package, which is implemented using the PEX framework. Do not use classes from the legacy EnsLib.JMS package, which may be removed in future releases.
Using the Business Operation
InterSystems provides a built-in business operation that can be used to messages to a JMS queue or topic without needing to write custom code. To use this business operation:
-
Add EnsLib.JMSPEX.BusinessOperation to your production. See Adding Business Hosts.
-
Configure settings of this business host as described in JMS Settings.
-
Configure other business hosts to send EnsLib.JMSPEX.MessageOpens in a new tab requests to this business operation. See JMS Message Class for details.
When this business operation receives a message of type EnsLib.JMSPEX.MessageOpens in a new tab, it sends that message to JMS.
JMS Message Class
The EnsLib.JMSPEX.MessageOpens in a new tab contains the following properties for defining the message:
-
destination defines the JMS queue or topic where the producer is sending messages.
-
type defines the message type ("Text" or "Bytes").
-
textBody or bytesBody defines the content of the message body. Of the two, set the property corresponding to the message type.
You can also use the properties property to attach metadata to your message. The properties property accepts a %ListOfObjectsOpens in a new tab collection of %External.Messaging.JMSMessagePropertyOpens in a new tab objects. See the documentation about the JMS API for further guidance on creating JMS message property objects. For general information about JMS message properties, refer to the JMS documentationOpens in a new tab.
Using the Adapter
If the built-in business operation does not meet your needs, you can directly use the JMS outbound adapter as follows:
-
Create a custom business operation class:
-
The class should extend Ens.BusinessOperationOpens in a new tab.
-
The ADAPTER parameter should equal EnsLib.JMSPEX.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 JMS outbound adapter has one instance method, named SendMessage(), with the following signature:
Method SendMessage(msg As EnsLib.JMSPEX.Message) As %Status{ }
-
-
Add your business operation to your production. See Adding Business Hosts.
-
Configure settings of this business host as described in JMS Settings.
-
Configure other business hosts to send requests to this business operation.
See Also
-
Using the JMS Messaging API (for use without a production)