camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james.strac...@gmail.com>
Subject Re: Sending Return From Bean Method To Queue
Date Mon, 07 Apr 2008 12:05:22 GMT
On 07/04/2008, greenbean <Kevin.Urciolo@ngc.com> wrote:
>
>  Newbie alert:  I am looking at Camel as a method to add better
>  workflow/routing behaviors to a system that uses Spring, ActiveMQ, and
>  Jencks to have POJOs consume and send JMS messages.
>
>  I read that a bean cannot be used as input.

It can be polled though.

from("bean:foo").to("activemq:cheese");

will poll the foo bean and then send its response to the cheese queue

> However, I am wondering why the
>  return from a bean method cannot be sent to a destination?  It would be nice
>  to have Camel call a bean method based on the contents of a message from a
>  JMS queue.

Oh it can do that...

from("activemq:someQueueName").bean("someBeanName");

using the message body to determine the method to invoke. Or you can
be specific...

from("activemq:someQueueName").bean("someBeanName", "someMethodName");

for more detail see...
http://activemq.apache.org/camel/bean-integration.html


>  It would also be nice to have the response from the method get
>  send to another queue based on some configuration without having to
>  explicity use a Template send method.

If the JMS message sent to the queue has a JMSReplyTo header then this
works now in 1.3.0...

from("activemq:someQueueName").bean("someBeanName", "someMethodName");

the response from the "someMethodName" method on someBeanName bean
will be returned to the JMSReplyTo queue.

If thats not good enough, you can explicitly specify the
queue/endpoint to send the response to.

from("activemq:someQueueName").bean("someBeanName", "someMethodName")
  .to("activemq:MyResponseQueue");


>  It would also be nice to be able to
>  route to a queue based on the contents of the response and route to a
>  different location if the an exception is thrown instead of a normal
>  response (and route based on the exception thrown).

Again you can use the content based router to do that...

from("activemq:someQueueName").bean("someBeanName", "someMethodName")
  .choice().
   ....

see http://activemq.apache.org/camel/content-based-router.html


>  Is there anything in Camel that allows this currently?  I suppose I could
>  write a proxy to wrap around beans and send JMS messages based on method
>  returns.  However, it would be great if Camel already did this and had the
>  routing logic to allow a basic type of workflow across JMS queues.

BTW there's also the Spring Remoting which does the proxy thing you
suggest; allowing you to invoke a proxy for any Java interface/base
class and underneath the covers do JMS messaging.
http://activemq.apache.org/camel/spring-remoting.html

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com

Mime
View raw message