2017-10-24 15:20:37 -04:00
|
|
|
# Mixed JMS and REST Producers/Consumers Example
|
2014-10-31 06:20:28 -04:00
|
|
|
|
|
|
|
This is an example of mixing JMS producers and consumers with REST producers and consumers. The REST clients have been
|
|
|
|
written in both Java using RESTEasy's client library and within the Python language. You will need Python 2.6.1 or higher
|
|
|
|
to be able to run the Python clients.
|
|
|
|
|
|
|
|
To run the example you will need 5 shell-script windows (or you'll need to run 4 processes in background)
|
|
|
|
|
|
|
|
Step 1:
|
2017-10-24 15:20:37 -04:00
|
|
|
|
|
|
|
mvn jetty:run
|
2014-10-31 06:20:28 -04:00
|
|
|
|
2015-05-13 06:12:07 -04:00
|
|
|
This will bring up ActiveMQ Artemis and the ActiveMQ Artemis REST Interface.
|
2014-10-31 06:20:28 -04:00
|
|
|
|
|
|
|
Step 2:
|
|
|
|
|
2017-10-24 15:20:37 -04:00
|
|
|
mvn exec:java -Dexec.mainClass="RestReceive"
|
|
|
|
|
|
|
|
This will bring up a Java REST client that is continuously pulling the broker through a consume-next (see doco for details).
|
2014-10-31 06:20:28 -04:00
|
|
|
|
|
|
|
Step 3:
|
2017-10-24 15:20:37 -04:00
|
|
|
|
|
|
|
mvn exec:java -Dexec.mainClass="JmsReceive"
|
2014-10-31 06:20:28 -04:00
|
|
|
|
|
|
|
This will bring up a Java JMS consumer that is using the MessageListener interface to consume messages. It will
|
|
|
|
extract a Order instance from the JMS Message it receives.
|
|
|
|
|
|
|
|
Step 4:
|
|
|
|
|
2017-10-24 15:20:37 -04:00
|
|
|
python receiveOrder.py
|
2014-10-31 06:20:28 -04:00
|
|
|
|
|
|
|
This runs a very simple Python program to consume messages
|
|
|
|
|
|
|
|
Step 5:
|
|
|
|
Use one of these three commands to post messages to the system. One of the receive clients will consume the message.
|
|
|
|
|
2017-10-24 15:20:37 -04:00
|
|
|
mvn exec:java -Dexec.mainClass="JmsSend"
|
2014-10-31 06:20:28 -04:00
|
|
|
|
|
|
|
A JMS client will create an Order object and send it to the queue. You'll see one of the 4 clients receive the message.
|
2017-10-24 15:20:37 -04:00
|
|
|
Notice that the REST clients automatically cause the Order object to be transformed on the broker and passed as XML
|
2014-10-31 06:20:28 -04:00
|
|
|
to the REST client.
|
|
|
|
|
2017-10-24 15:20:37 -04:00
|
|
|
mvn exec:java -Dexec.mainClass="RestSend"
|
2014-10-31 06:20:28 -04:00
|
|
|
|
2017-10-24 15:20:37 -04:00
|
|
|
This is a REST client that uses the Acknowledgement protocol to receive a message from the queue.
|
2014-10-31 06:20:28 -04:00
|
|
|
|
2017-10-24 15:20:37 -04:00
|
|
|
python postOrder.py
|
2014-10-31 06:20:28 -04:00
|
|
|
|
|
|
|
This is a Python client that posts one message to the queue RESTfully (of course ;) )
|