Routing a request asynchronously
When you send a message using the ProducerTemplate.sendBody()
method into a Camel endpoint, you may find that even though it contains asynchronous processing, such as through the threads
DSL (see the Spreading the load within a route using a set of threads recipe), your original thread is blocked until the request is fully processed. This is by design, as Camel will not return unless the message was fully processed—keeping track of whether an exchange was fully processed is one of the roles of Camel's Asynchronous Routing Engine.
This recipe will explain how to interact with Camel asynchronously through a ProducerTemplate
instance, so that you can continue doing other work while a message submitted to Camel is being processed.
Getting ready
Java code for this recipe is located in the org.camelcookbook.parallelprocessing.asyncrequest
package.
This recipe assumes that you have an existing route that will process a message synchronously, and may take...