...
When you start the example up you'll see a whole bunch of logs that won't really mean anything to you The interesting stuff is happening in the background. Here's a diagram of whats going on.
TODO
At step 1 the SendFileRecordsToQueueBean polls the ./src/data directory for new files. There are 3 files in this directory so 3 messages will be created. As shown below, the @Consume annotation will cause any new messages coming from the file:src/data endpoint to be sent to the onFileSendToQueue method.
Wiki Markup |
---|
{snippet:id=ex|lang=java|url=camel/trunk/examples/camel-example-pojo-messaging/src/main/java/org/apache/camel/example/pojo_messaging/SendFileRecordsToQueueBean.java} |
At step 2 the SendFileRecordsToQueueBean then sends the contents of the File message as a String to the personnel.records JMS queue, which is backed by an embedded instance of Apache ActiveMQ. The conversion from String to JMS message is automatic. The @EndpointInject annotation is used to access the ActiveMQ endpoint.
At step 3 the DistributeRecordsBean (shown below) consumes the JMS message from the personnel.records queue. Again the @Consume annotation is used to get messages from the ActiveMQ endpoint.
Wiki Markup |
---|
{snippet:id=ex|lang=java|url=camel/trunk/examples/camel-example-pojo-messaging/src/main/java/org/apache/camel/example/pojo_messaging/DistributeRecordsBean.java} |
You will notice an additional @RecipientList annotation on the route method. This turns the method into a recipient list EIP where the return value is a list of URIs for the recipients. This annotation is great for creating custom dynamic recipient lists. In this case at step 4 we peek at the city field in the message (using the @XPath annotation) and provide a set of recipients based on that. For folk from London, their files will be sent to file locations for the EMEA region (file:target/messages/emea/...). Others fall into the AMER region (file:target/messages/amer/...).