Skip to main content


class EnsLib.JMSTest extends %Library.RegisteredObject

This class is designed to demonstrate how to connect to a JMS server in Ensemble by using the Java Gateway. If this is the first time you are running the test please follow these prerequisite steps:

1) Download and install a JMS server -- in this example ActiveMQ is used.

2) Start the JMS server. For ActiveMQ, navigate to the /bin subdirectory of the installation directory and run "activemq start"

3) Start the Java Gateway and run the InitializeTest method providing the location of the JMS broker jar. For example, a recently installed version of ActiveMQ could be in: "C:\activemq\activemq-all-5.14.0.jar"

4) Call "do ##class(EnsLib.JMSTest).RunTest()" from terminal to run the test, passing the appropriate arguments. If the Java Gateway is running on the local machine at port 5555, and the JMS Server is running on the localmachine at port 61616, run: do ##class(EnsLib.JMSTest).RunTest("localhost",5555,"tcp://localhost:61616"). The third argument specifies the transport protocol followed by the address where the JMS server can be found.

To run an interactive version of the test, open two cache terminals. In one, call "do ##class(EnsLib.JMSTest).TestProducer("localhost",5555,"tcp://localhost:61616")" and in the other call "do ##class(EnsLib.JMSTest).TestConsumer("localhost",5555,"tcp://localhost:61616")". The producer's terminal will prompt for messages which should be displayed shortly in the consumer's terminal. Press enter to send. To exit type "QUIT" or "quit".

Please look at the specifics of the methods below for more details. In general this example is an adaptation of the "Hello World" example from Apache ActiveMQ. Specifically versions of the HelloWorldProducer and HelloWorldConsumer are implemented in COS. The original example can be found here: in a new tab

Method Inventory


classmethod InitializeTest(pJMSBrokerJar As %String = "", pGatewayHost As %String = "localhost", pGatewayPort As %String = 5555)
classmethod RunTest(pGatewayHost As %String = "localhost", pGatewayPort As %String = 5555, pBrokerAddress As %String = "vm://localhost")
classmethod TestConsumer(pGatewayHost As %String = "localhost", pGatewayPort As %String = 5555, pBrokerAddress As %String = "vm://localhost", pInteractive As %Boolean = 1)
classmethod TestProducer(pGatewayHost As %String = "localhost", pGatewayPort As %String = 5555, pBrokerAddress As %String = "vm://localhost", pInteractive As %Boolean = 1)

Inherited Members

Inherited Methods

FeedbackOpens in a new tab