...
Code Block |
---|
mvn jetty:run-war |
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.
Use Web Console to add load balance support
For a handful of small messages, one queue is enough to handle. But when encountering high volumn message input, we may want to use several queues to provide a load balance mechanism. So we can use the camel Load Balancer support. The message service improvement here is much easier than that in other messaging system.
Use a loadBalance DSL for the message delivery on route1:
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.