camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From runr <>
Subject Re: WebLogic JMS request to EJB method to JMS response
Date Wed, 16 Apr 2008 17:22:34 GMT


Thanks for your response.  It was quite helpful.  I had been working with
Camel 1.2 still and it had not worked as you described - no reply was being
sent to the JMSReplyTo queue after the EJB method invocation.

I went ahead and upgraded to Camel 1.3 and retried, obtaining different (and
improved) behavior.  Your answer works well when the EJB invocation returns
whatever is expected to be received by the JMS client that is awaiting the

In my use case scenario, the JMS client was expecting a custom message
object to be returned, whereas the EJB methods I was invoking return either
a double or void.

So, I modified the JmsToEjbMethod Processor that was invoked before the EJB
invocation, to store the received custom message object as an Exchange
property, and I then retrieved and updated this custom message object in the
EjbMethodToJms Processor that was invoked upon return from the EJB
invocation.  After updating the custom message object with the response
info, I replace the in Message's body with my custom message object using
in.setBody().  The custom message object is then automatically returned by
Camel to the JMS client.  So my route looks like this:

JmsToEjbMethod()).to("bean:ejbProxy").process(new EjbMethodToJms());

In this scenario, I needed to preserve some information across the EJB
method's invocation.  In my JmsToEjbMethod Processor, I added a property to
the Exchange to hold this information (i.e., the custom message object).  Is
that an appropriate usage of an Exchange property?

Again, thanks!

Russ Evans

RomKal wrote:
> 2008/4/14, runr <>:
>>  I have a use case where a JMS client sends an ObjectMessage to a
>> WebLogic
>>  JMS queue.  Using Camel, I retrieve the message off the queue and route
>> it
>>  to a JmsToEjbMethod Processor implementation.  The Processor obtains the
>>  parameters needed to invoke an EJB method from the JMS message,
>> populates an
>>  Object array and instantiates a BeanInvocation that specifies the
>>  appropriate EJB method and contains the Object array of the method's
>>  parameters.
>>  The EJB method is then invoked and returns fine.
>>  Then I need to re-transform the response for the JMSReplyTo temporary
>> queue
>>  that the original JMS client is listening on.  I am able to accomplish
>> this
>>  with another Processor implementation - EjbMethodToJms.
>>  In order to send the JMS response message back to the JMSReplyTo queue,
>> I
>>  had to re-obtain a QueueConnectionFactory, get a QueueConnection, and
>> create
>>  a QueueSession in order to send the response message back.  I could not
>>  figure out a way to get access to the original JMS request's
>> QueueSession in
>>  the first JmsToEjbMethod Processor to save in a Header for using when
>> the
>>  second EjbMethodToJms Processor wants to send the awaited response.
>>  Is there a means by which I can maintain the session to the JMS queue
>> across
>>  the EJB method call to send the expected response?
>>  Does this sound like a reasonable approach for accomplishing this
>>  integration, or is there a better way?
> It looks that what you want to do can be done automatically.
> When you specify from("jms:inQueue") and if the message received
> contains JMSReplyTo (that is the case) then your exchange is InOut. It
> means, that any outcome from your flow will be automatically replied
> to JMSReplyTo queue.
> So I believe it should be enough to do something like this (if I
> correctly understand what JmsToEjbMethod class does):
> from("jms:inQueue").process(new JmsToEjbMethod()).to("bean:ejbProxy");
> then, the response from your EJB invocation is simply returned back to
> jms:inQueue endpoint that uses original JMSReplyTo queue/topic to send
> the response.
> I hope it helps,
> Roman

View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message