...
After started, we can view the routes configured in camel context by directing your browser to http://localhost:8080/routes.
There are originally several message files in the directory: src/data and the message system processes them once it is started. We can get the processing result by checking the console and the files in target/messages.
...
Code Block |
---|
from("file:src/data?noop=true").convertBodyTo(java.lang.String.class).to("stream:out") .loadBalance().random() .to("activemq:personnel.records1") .to("activemq:personnel.records2") .end() |
Let the route2 collect messages from both queues providing the load balance support:
Code Block |
---|
from("activemq:personnel.records1", "activemq:personnel.records2") .choice() .when().xpath("/person/city = 'London'").to("file:target/messages/uk") .otherwise().to("file:target/messages/others") .end() |
With these two operations, you have complete this work. Just throw your message into the directory, camel will process and deliver it automatically. By the way, you may need some Dead Letter Channel configuration for it since XML analyzing with rigid format usually accompanies frequent error.