You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by runr <ru...@freddiemac.com> on 2008/04/14 21:50:27 UTC

WebLogic JMS request to EJB method to JMS response

Hi,

I am a new Camel user and I have been experimenting with Camel's routing and
transformation capabilities.

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?

Thanks,

Russ Evans


-- 
View this message in context: http://www.nabble.com/WebLogic-JMS-request-to-EJB-method-to-JMS-response-tp16688628s22882p16688628.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: WebLogic JMS request to EJB method to JMS response

Posted by Roman Kalukiewicz <ro...@gmail.com>.
2008/4/16, runr <ru...@freddiemac.com>:
>
>  Roman,
>
>  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.

Well - as you noticed there are a lot of changes since 1.2 ;)

>  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
>  response.
>
>  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:
>
>
>  from("jms:inQueue").process(new
>
> 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?

This is exactly what properties are for.

Basically we have two different things: headers (on messages) and
properties (on exchanges). Headers tries to be sent via
endpoint-specific technology to a recepient (like properties on JMS
message). They are usually lost at the endpoint (response JMS message
doesn't have the same properties that request).
In case of properties they they are not represented (usually) using
underlying technology, so they are not lost. If you want to keep some
information until you explicitely remove it properties are your
choice.

>  Again, thanks!

You are welcome,
Roman

Re: WebLogic JMS request to EJB method to JMS response

Posted by runr <ru...@freddiemac.com>.
Roman,

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
response.

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:

from("jms:inQueue").process(new
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 <ru...@freddiemac.com>:
>>  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: http://www.nabble.com/WebLogic-JMS-request-to-EJB-method-to-JMS-response-tp16688628s22882p16724653.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: WebLogic JMS request to EJB method to JMS response

Posted by Roman Kalukiewicz <ro...@gmail.com>.
2008/4/14, runr <ru...@freddiemac.com>:
>  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