Load Balance for existing Messaging ServicePage edited by Xueqiang MiLoad Balance for Existing Messaging ServiceThis is a sample to show how we can change our existing messaging service for requirement or improvement. Here we use a load balance support as example. Build the sampleImagine that we have a message handling system built before to collect some information from our client and then process and record them. This scenario can be constructed by using the following XML route configuration. <route> <from uri="file:src/data?noop=true"/> <!-- Print the message to standard out, just as a test --> <convertBodyTo type="java.lang.String"/> <to uri="stream:out"/> <to uri="activemq:personnel.records"/> </route> <route> <from uri="activemq:personnel.records"/> <choice> <when> <xpath>/person/city = 'London'</xpath> <to uri="file:target/messages/uk"/> </when> <otherwise> <to uri="file:target/messages/others"/> </otherwise> </choice> </route> For more instruction to build your sample, read the Camel Maven Archetypes page. The above routes are the default configuration for your new sample, so you can get started with it easily. mvn jetty:run-war After started, we can view the routes configured in camel context by directing your browser to http://localhost:8080/routes. Use Web Console to add load balance supportFor 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. 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: 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.
Change Notification Preferences
View Online
|
View Change
|
Add Comment
|
- [CONF] Apache Camel > Load Balance for existing Messaging Se... confluence
- [CONF] Apache Camel > Load Balance for existing Messagi... confluence
- [CONF] Apache Camel > Load Balance for existing Messagi... confluence
- [CONF] Apache Camel > Load Balance for existing Messagi... confluence
- [CONF] Apache Camel > Load Balance for existing Messagi... confluence