This example illustrates how Smooks can be used to split a message into smaller messages and route the smaller messages to a JMS Destination.
This example uses Smooks to process an input Order message, splitting it into smaller Order Item messages and routing them to a JMS Destination.
See:
- The Smooks configuration in splitter-router/smooks-config.xml. Specifically, take a look at the JMSRouter resource configuration and how it uses the "highWaterMark" param to throttle split file generation to the JMS Queue.
- The "Main" class in splitter-router/src/main/java/example/Main.java. This is the class that executes smooks to split Order messages into smaller Order Item messages.
- The "Main" class in jms-consumer/src/main/java/example/Main.java. This is the class that "consumes" the order-item messages as they are delivered to the JMS Queue.
- The input-message.xml file in the root folder of the example.
Running:
- In the "jms-router" directory, run "mvn clean install".
- Open a new console window ("Window 1")
- In "Window 1", change directory into the "jms-provider" directory.
- In "Window 1", run "mvn activemq:run".
- Open a new console window ("Window 2")
- In "Window 2", change directory into the "jms-consumer" directory.
- In "Window 2", run "mvn exec:exec".
- Open a new console window ("Window 3")
- Arrange "Window 1", "Window 2" and "Window 3" such that the contents of all windows is visible at the same time.
- In "Window 3", change directory into the "splitter-router" directory.
- In "Window 3", run "mvn exec:exec". This executes a Smooks instance to process the input-message.xml. Follow the on-screen instructions and you will see Smooks throttling against the High Water Mark ("Window 3") while the messages are being slowly consumed by the jms-consumer ("Window 2").
Monitoring (optional):
- export MAVEN_OPTS=-Dcom.sun.management.jmxremote
- "jconsole"