How to connect an Apache Camel synchronous request / response endpoint with asynchronous subpoints

I would like to redirect the webservice request to the InOnly endpoint in the jms queue. Then forward the jms response message received from the individual InOnly endpoint back to the webservice client service as a response. The request / response webservice is a synchronous InOut template, and the sub-item is an asynchronous one. What options should I follow with Camel?

Camel route is used to explain my question:

String uri={webserice uri}
from(uri)    
    .process(new Processor() {
        public void process(Exchange exchange) throws Exception {
            ServcieRequest req =            
            exchange.getIn().getBody(ServcieRequest.class);                 
            // One option to me is to spawn another route here to route to jms queue...         
            ProducerTemplate template = exchange.getContext().createProducerTemplate();
            template.sendBodyAndHeaders("jms:queue:INQueue", req.getPayload(), headers);
            // then need to wait ...until received jms response from the route below        

   }});


from("jms:queue:OUTQueue")
   .process(new Processor() {
       public void process(Exchange exchange) throws Exception {
           // received jms response message
           // need to update the exchange data in the above route based on jms message
           // so the final response to the webservice cilent can receive the data ...
       }});
+3
source share
1 answer

I think you should rely on Camel's query response mechanism for this task. Camel Doc, Exclusive Fixed Response Queue

, , DSL , ( , InOnly JMS?). , requestTimeout, ( 20 ).

from(webserviceURI)
  .inOut().to("jms:queue:INQueue?replyTo=OUTQueue?replyToType=Exclusive");

, . , node.

+2

All Articles