Defining a connection point for JMS messages
This section explains how to define a Message Queue Server connection point to read or write JMS messages to or from external applications. This is only relevant, if you define the message queue connection point as a JMS provider. The examples in this section are ActiveMQ-specific.
To get started with ActiveMQ, download the examples from the ActiveMQ download site.
See http://activemq.apache.org/download.html.
The download contains an example folder. The examples use the apache ActiveMQ server to connect to, and read or write messages. Prerequisites for these examples are a Java SDK and the ant build tool.
You can use two examples, Producer and Consumer, to see messages flowing from Producer to the ActiveMQ server to Consumer. Complete these steps:
- To start the server, run this command from the command line:
bin/activemq console
- To start the Consumer, run this command:
ant consumer
- To start the Producer, run this
command:
ant producer
2000 text messages are sent now from Producer to the message queue named TEST.FOO at
tcp://localhost:61616
, which is created by the ActiveMQ server. The messages are received by Consumer, which is listening to that created queue.
Instead of this example server, you can model a document flow, which performs almost the same, in ION. In ION, these connection points are modeled:
- A Message Queue connection point to which Producer can send its messages.
- Another connection point from which Consumer can receive its messages.
The ION engine routes the messages from one connection point to another.
Points of attention:
- Model the Producer connection point
with these properties:
- url: tcp://localhost:61616
- Queue for Reading: TEST.FOO
Document settings depend on the messages that are written to the queue. Select a BOD and select the Read from Queue check box.
- Model the Consumer connection point
with these properties:
- url: tcp://localhost:61618
- Queue for Writing: TEST.FOO
Document settings depend on the messages that are read from the queue. Select a BOD and select the Write to Queue check box.
The difference between the example and the model is that the Consumer should not directly read from port 61616. The ION engine is reading this queue instead. ION routes the incoming messages to all connection points which are modeled.
In the modeled flow messages are coming in at port 61616 of the incoming adapter and are routed to the outgoing adapter with port 61618. The Consumer example receives 2000 messages from port 61616 by default; in this case it should be overruled by:
ant -Durl=tcp://localhost:61618 consumer - Dmax=1
The Producer example sends text messages which are received by Consumer. ION cannot receive or send plain text messages, only xml messages are allowed.
See Message Queue connection points.
Therefore, you must change the Producer example so that the message is xml. Reading a file which contains a Full BOD is convenient; in that case you can replace the createMessageText() method in src/Producer.java by this example:
private String createMessageText(int index) {
File file = new File("bod.xml");
String content = "";
try {
content = FileUtils.readFileToString(file);
} catch (IOException e) {
e.printStackTrace();
}
return content;
}
You can overrule the default of producing 2000 messages by:
ant producer -Dmax=1
With these settings one message that contains the content of bod.xml is sent to ION.