You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by GLD <gu...@orange-ftgroup.com> on 2008/12/08 19:29:54 UTC

WS => JMS with 2 queues

Hi, 
I try to implement the following use case

A Direct-endpoint consumes data 
    ==> request data is sent the request via JMS in queue "requestQueue" AND 
the reply is expected on the queue "responseQueue" 
       ==> The reply is then sent back tot the direct-endpoint


I tried to 
  add a correlationID to the request=)
  use a multicast tag (to send the JMS message) and to prepare a join point
for the reply. In the second exchange, I set the header 'isReply' to false. 

In the route consuming the JMS reply from queue "responseQueue", I set the
header 'isReply' to 'true'  (so 1 has isReply to true and the other to
false).
I tried to use an aggregator to join both exhanges above sending them to the
same direct endpoint.
  The matching is done via the JMScorrelationID
  The choice is done by a custom strategy (The Selected exchange is the one
where 'isReply = true'

(see route file attached
http://www.nabble.com/file/p20900905/applicationContext-business-camel-route.xml
applicationContext-business-camel-route.xml 


... But it doesn't work.
  My expected "join point" doesn't wait for the reply.... and the request is
sent back to the "Direct-endpoint":-(
 

What is the good solution to make the thread that process the original
message wait for a message processed by another thread?

NB : One of my requirements is to use 2 queues. I did it with 1 queue
(InOut) and it works fine.=)

Regards

-- 
View this message in context: http://www.nabble.com/WS-%3D%3E-JMS-with-2-queues-tp20900905s22882p20900905.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: WS => JMS with 2 queues

Posted by Willem Jiang <wi...@gmail.com>.
Hi,

Did you try to use the multicast?

Here is the example codes of multicast , thread A will wait for the
response back and finishing the response aggregation.
// Router 1 to call the bank endpoints sequentially
from(Constants.LOANBROKER_URI)
    // Using the CreditScoreProcessor to call the credit agency service
    .process(new CreditScoreProcessor(Constants.CREDITAGENCY_ADDRESS))
        // Set the aggregation strategy on the multicast pattern
        .multicast(new BankResponseAggregationStrategy())
            // Send out the request the below three different banks
sequentially
            .to(Constants.BANK1_URI, Constants.BANK2_URI,
Constants.BANK3_URI);

// Router 2 to call the bank endpoints parallelly
from(Constants.PARALLEL_LOANBROKER_URI)
    .process(new CreditScoreProcessor(Constants.CREDITAGENCY_ADDRESS))
        // Using the thread pool to send out message to the below three
different banks parallelly
        .multicast(new BankResponseAggregationStrategy())
            // Camel will create a thread pool with the size of the send
to endpoints
            // for sending the message parallelly
            .setParallelProcessing(true)
            .to(Constants.BANK1_URI, Constants.BANK2_URI,
Constants.BANK3_URI);

You can find more information about this loan broker example here[1]

[1] http://activemq.apache.org/camel/loan-broker-example.html


Willem


GLD wrote:
> I didn't see this property. 
> By the way, the setter is JmsConfiguration.setReplyTo().
> ==> 
>   <to
> uri="jms:queue:${request.queue}?replyToDestination=queue:${reply.queue}"/>
> Fails
>   <to uri="jms:queue:${request.queue}?replyTo=queue:${reply.queue}"/>  is
> OK.
> 
> =====
> And just for my personal knowledge, In an InOut Pattern, consuming a message
> (in thread A), how do you 
>   - send 2 Messages (InOut) at the same time
>   - make the Thread A wait for the 2 responses  
>   - continue the initial route
>                                 
>                                 send request       receive reply
>           thread A           /------------  ..... -----------\     aggregate
> responses 
>    ==> Endpoint ------<                                          
>> ---------------------- ..... continue
>                                 \------------  ..... -----------/
> 
> or  
>                                
>           thread A         Send Asynch        Wait for the 2          
> aggregate 
>    ==> Endpoint ------   Req 1 &2   ----- asynch Responses -- responses
> --------- ..... continue 
> 
> 
> Regards
> 
> 
> willem.jiang wrote:
>> +1 for Christian's solution.
>> For the WS the communication model is a request/response, so the message
>> exchange pattern is InOut. Current camel jms component does not only
>> support InOnly pattern, but also support InOut pattern.
>>
>> Willem
>>
>> Christian Schneider wrote:
>>> Your config looks extremely complex.
>>>
>>> Shouldn´t a simple
>>>
>>> <from uri="direct:myEndpoint"/>
>>> <to
>>> uri="jms:queue:${request.queue.jndi-name}?replyToDestination=queue:${reply.queue.jndi-name}"/>
>>>
>>>
>>> suffice?
>>>
>>> As far as I know it will do a nice request / reply with correlation id
>>> processing.
>>>
>>> Greetings
>>>
>>> Christian
>>>
>>> GLD schrieb:
>>>> Hi, I try to implement the following use case
>>>>
>>>> A Direct-endpoint consumes data     ==> request data is sent the
>>>> request via JMS in queue "requestQueue" AND the reply is expected on
>>>> the queue "responseQueue"        ==> The reply is then sent back tot
>>>> the direct-endpoint
>>>>
>>>>
>>>> I tried to   add a correlationID to the request=)
>>>>   use a multicast tag (to send the JMS message) and to prepare a join
>>>> point
>>>> for the reply. In the second exchange, I set the header 'isReply' to
>>>> false.
>>>> In the route consuming the JMS reply from queue "responseQueue", I set
>>>> the
>>>> header 'isReply' to 'true'  (so 1 has isReply to true and the other to
>>>> false).
>>>> I tried to use an aggregator to join both exhanges above sending them
>>>> to the
>>>> same direct endpoint.
>>>>   The matching is done via the JMScorrelationID
>>>>   The choice is done by a custom strategy (The Selected exchange is
>>>> the one
>>>> where 'isReply = true'
>>>>
>>>> (see route file attached
>>>> http://www.nabble.com/file/p20900905/applicationContext-business-camel-route.xml
>>>>
>>>> applicationContext-business-camel-route.xml
>>>>
>>>> ... But it doesn't work.
>>>>   My expected "join point" doesn't wait for the reply.... and the
>>>> request is
>>>> sent back to the "Direct-endpoint":-(
>>>>  
>>>>
>>>> What is the good solution to make the thread that process the original
>>>> message wait for a message processed by another thread?
>>>>
>>>> NB : One of my requirements is to use 2 queues. I did it with 1 queue
>>>> (InOut) and it works fine.=)
>>>>
>>>> Regards
>>>>
>>>>   
>>>
>>
>>
> 


Re: WS => JMS with 2 queues

Posted by GLD <gu...@orange-ftgroup.com>.
I didn't see this property. 
By the way, the setter is JmsConfiguration.setReplyTo().
==> 
  <to
uri="jms:queue:${request.queue}?replyToDestination=queue:${reply.queue}"/>
Fails
  <to uri="jms:queue:${request.queue}?replyTo=queue:${reply.queue}"/>  is
OK.

=====
And just for my personal knowledge, In an InOut Pattern, consuming a message
(in thread A), how do you 
  - send 2 Messages (InOut) at the same time
  - make the Thread A wait for the 2 responses  
  - continue the initial route
                                
                                send request       receive reply
          thread A           /------------  ..... -----------\     aggregate
responses 
   ==> Endpoint ------<                                          
>---------------------- ..... continue
                                \------------  ..... -----------/

or  
                               
          thread A         Send Asynch        Wait for the 2          
aggregate 
   ==> Endpoint ------   Req 1 &2   ----- asynch Responses -- responses
--------- ..... continue 


Regards


willem.jiang wrote:
> 
> +1 for Christian's solution.
> For the WS the communication model is a request/response, so the message
> exchange pattern is InOut. Current camel jms component does not only
> support InOnly pattern, but also support InOut pattern.
> 
> Willem
> 
> Christian Schneider wrote:
>> Your config looks extremely complex.
>> 
>> Shouldn´t a simple
>> 
>> <from uri="direct:myEndpoint"/>
>> <to
>> uri="jms:queue:${request.queue.jndi-name}?replyToDestination=queue:${reply.queue.jndi-name}"/>
>> 
>> 
>> suffice?
>> 
>> As far as I know it will do a nice request / reply with correlation id
>> processing.
>> 
>> Greetings
>> 
>> Christian
>> 
>> GLD schrieb:
>>> Hi, I try to implement the following use case
>>>
>>> A Direct-endpoint consumes data     ==> request data is sent the
>>> request via JMS in queue "requestQueue" AND the reply is expected on
>>> the queue "responseQueue"        ==> The reply is then sent back tot
>>> the direct-endpoint
>>>
>>>
>>> I tried to   add a correlationID to the request=)
>>>   use a multicast tag (to send the JMS message) and to prepare a join
>>> point
>>> for the reply. In the second exchange, I set the header 'isReply' to
>>> false.
>>> In the route consuming the JMS reply from queue "responseQueue", I set
>>> the
>>> header 'isReply' to 'true'  (so 1 has isReply to true and the other to
>>> false).
>>> I tried to use an aggregator to join both exhanges above sending them
>>> to the
>>> same direct endpoint.
>>>   The matching is done via the JMScorrelationID
>>>   The choice is done by a custom strategy (The Selected exchange is
>>> the one
>>> where 'isReply = true'
>>>
>>> (see route file attached
>>> http://www.nabble.com/file/p20900905/applicationContext-business-camel-route.xml
>>>
>>> applicationContext-business-camel-route.xml
>>>
>>> ... But it doesn't work.
>>>   My expected "join point" doesn't wait for the reply.... and the
>>> request is
>>> sent back to the "Direct-endpoint":-(
>>>  
>>>
>>> What is the good solution to make the thread that process the original
>>> message wait for a message processed by another thread?
>>>
>>> NB : One of my requirements is to use 2 queues. I did it with 1 queue
>>> (InOut) and it works fine.=)
>>>
>>> Regards
>>>
>>>   
>> 
>> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/WS-%3D%3E-JMS-with-2-queues-tp20900905s22882p20911586.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: WS => JMS with 2 queues

Posted by Willem Jiang <wi...@gmail.com>.
+1 for Christian's solution.
For the WS the communication model is a request/response, so the message
exchange pattern is InOut. Current camel jms component does not only
support InOnly pattern, but also support InOut pattern.

Willem

Christian Schneider wrote:
> Your config looks extremely complex.
> 
> Shouldn´t a simple
> 
> <from uri="direct:myEndpoint"/>
> <to
> uri="jms:queue:${request.queue.jndi-name}?replyToDestination=queue:${reply.queue.jndi-name}"/>
> 
> 
> suffice?
> 
> As far as I know it will do a nice request / reply with correlation id
> processing.
> 
> Greetings
> 
> Christian
> 
> GLD schrieb:
>> Hi, I try to implement the following use case
>>
>> A Direct-endpoint consumes data     ==> request data is sent the
>> request via JMS in queue "requestQueue" AND the reply is expected on
>> the queue "responseQueue"        ==> The reply is then sent back tot
>> the direct-endpoint
>>
>>
>> I tried to   add a correlationID to the request=)
>>   use a multicast tag (to send the JMS message) and to prepare a join
>> point
>> for the reply. In the second exchange, I set the header 'isReply' to
>> false.
>> In the route consuming the JMS reply from queue "responseQueue", I set
>> the
>> header 'isReply' to 'true'  (so 1 has isReply to true and the other to
>> false).
>> I tried to use an aggregator to join both exhanges above sending them
>> to the
>> same direct endpoint.
>>   The matching is done via the JMScorrelationID
>>   The choice is done by a custom strategy (The Selected exchange is
>> the one
>> where 'isReply = true'
>>
>> (see route file attached
>> http://www.nabble.com/file/p20900905/applicationContext-business-camel-route.xml
>>
>> applicationContext-business-camel-route.xml
>>
>> ... But it doesn't work.
>>   My expected "join point" doesn't wait for the reply.... and the
>> request is
>> sent back to the "Direct-endpoint":-(
>>  
>>
>> What is the good solution to make the thread that process the original
>> message wait for a message processed by another thread?
>>
>> NB : One of my requirements is to use 2 queues. I did it with 1 queue
>> (InOut) and it works fine.=)
>>
>> Regards
>>
>>   
> 
> 


Re: WS => JMS with 2 queues

Posted by Christian Schneider <ch...@die-schneider.net>.
Your config looks extremely complex.

Shouldn´t a simple

<from uri="direct:myEndpoint"/>
<to uri="jms:queue:${request.queue.jndi-name}?replyToDestination=queue:${reply.queue.jndi-name}"/>

suffice?

As far as I know it will do a nice request / reply with correlation id processing.

Greetings

Christian

GLD schrieb:
> Hi, 
> I try to implement the following use case
>
> A Direct-endpoint consumes data 
>     ==> request data is sent the request via JMS in queue "requestQueue" AND 
> the reply is expected on the queue "responseQueue" 
>        ==> The reply is then sent back tot the direct-endpoint
>
>
> I tried to 
>   add a correlationID to the request=)
>   use a multicast tag (to send the JMS message) and to prepare a join point
> for the reply. In the second exchange, I set the header 'isReply' to false. 
>
> In the route consuming the JMS reply from queue "responseQueue", I set the
> header 'isReply' to 'true'  (so 1 has isReply to true and the other to
> false).
> I tried to use an aggregator to join both exhanges above sending them to the
> same direct endpoint.
>   The matching is done via the JMScorrelationID
>   The choice is done by a custom strategy (The Selected exchange is the one
> where 'isReply = true'
>
> (see route file attached
> http://www.nabble.com/file/p20900905/applicationContext-business-camel-route.xml
> applicationContext-business-camel-route.xml 
>
>
> ... But it doesn't work.
>   My expected "join point" doesn't wait for the reply.... and the request is
> sent back to the "Direct-endpoint":-(
>  
>
> What is the good solution to make the thread that process the original
> message wait for a message processed by another thread?
>
> NB : One of my requirements is to use 2 queues. I did it with 1 queue
> (InOut) and it works fine.=)
>
> Regards
>
>   


-- 

Christian Schneider
---
http://www.liquid-reality.de