You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Jens <sm...@dzbank.de> on 2013/07/22 10:37:53 UTC

JMS Transport: Overriding ReplyDestination

Hi,

is there a way to override the JMS ReplyDestination on the service
implementor side even if the client sends the request with the JMSReplyTo
field set? It looks like the destination from the message always takes
precedence over the value from the JMSConfiguration but I need it the other
way around. Something like "ignore JMSReplyTo" would work as well.

Thanks,
Jens



--
View this message in context: http://cxf.547215.n5.nabble.com/JMS-Transport-Overriding-ReplyDestination-tp5731199.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: JMS Transport: Overriding ReplyDestination

Posted by Jens <sm...@dzbank.de>.
Daniel  Kulp wrote
> Looking in the code:
> 
>     public Destination getReplyToDestination(JmsTemplate jmsTemplate,
> Message inMessage) throws JMSException {
>         javax.jms.Message message =
> (javax.jms.Message)inMessage.get(JMSConstants.JMS_REQUEST_MESSAGE);
>         // If WS-Addressing had set the replyTo header.
>         final String replyToName =
> (String)inMessage.get(JMSConstants.JMS_REBASED_REPLY_TO);
>         if (replyToName != null) {
>             return resolveDestinationName(jmsTemplate, replyToName);
>         } else if (message.getJMSReplyTo() != null) {
>             return message.getJMSReplyTo();
>         } else if (!StringUtils.isEmpty(jmsConfig.getReplyDestination()))
> {
>             return resolveDestinationName(jmsTemplate,
> jmsConfig.getReplyDestination());
>         } else {
>             throw new RuntimeException("No replyTo destination set on
> request message or cxf message");
>         }
>     }
> 
> Thus, if you have an interceptor or similar on the chain, you should be
> able to set the JMSConstants.JMS_REBASED_REPLY_TO property on the IN
> message to something else and it should be picked up.

I'll give that a shot.

Thanks,
Jens



--
View this message in context: http://cxf.547215.n5.nabble.com/JMS-Transport-Overriding-ReplyDestination-tp5731199p5731255.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: JMS Transport: Overriding ReplyDestination

Posted by Daniel Kulp <dk...@apache.org>.
On Jul 22, 2013, at 11:01 AM, Jens <sm...@dzbank.de> wrote:

> Daniel  Kulp wrote
>>> In this case I receive the request via a JMS "proxy," and the original
>>> ReplyTo queue is inaccessible to my service. Instead I need to send the
>>> reply back to the proxy which will then forward it to the client (this
>>> could
>>> be done by keeping JMSReplyTo intact, I suppose, but we're using fixed
>>> queues anyway so that's unnecessary in this case; effectively, the client
>>> could also just not set JMSReplyTobut it's an external source and out of
>>> my
>>> control unfortunately).
>> 
>> Shouldn't the JMS proxy then be setting a new JMSReplyTo on the message to
>> one that it can remap?
> 
> It would be nice if it did but it's really more of a proxy look-alike and
> there are technical reasons why it cannot modify the proxied messages. If
> CXF cannot ignore the JMSReplyTo field, however, we have little choice but
> to build our own "true" proxy to do just that.


Looking in the code:

    public Destination getReplyToDestination(JmsTemplate jmsTemplate, Message inMessage) throws JMSException {
        javax.jms.Message message = (javax.jms.Message)inMessage.get(JMSConstants.JMS_REQUEST_MESSAGE);
        // If WS-Addressing had set the replyTo header.
        final String replyToName = (String)inMessage.get(JMSConstants.JMS_REBASED_REPLY_TO);
        if (replyToName != null) {
            return resolveDestinationName(jmsTemplate, replyToName);
        } else if (message.getJMSReplyTo() != null) {
            return message.getJMSReplyTo();
        } else if (!StringUtils.isEmpty(jmsConfig.getReplyDestination())) {
            return resolveDestinationName(jmsTemplate, jmsConfig.getReplyDestination());
        } else {
            throw new RuntimeException("No replyTo destination set on request message or cxf message");
        }
    }

Thus, if you have an interceptor or similar on the chain, you should be able to set the JMSConstants.JMS_REBASED_REPLY_TO property on the IN message to something else and it should be picked up.


-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com


Re: JMS Transport: Overriding ReplyDestination

Posted by Jens <sm...@dzbank.de>.
Daniel  Kulp wrote
>> In this case I receive the request via a JMS "proxy," and the original
>> ReplyTo queue is inaccessible to my service. Instead I need to send the
>> reply back to the proxy which will then forward it to the client (this
>> could
>> be done by keeping JMSReplyTo intact, I suppose, but we're using fixed
>> queues anyway so that's unnecessary in this case; effectively, the client
>> could also just not set JMSReplyTobut it's an external source and out of
>> my
>> control unfortunately).
> 
> Shouldn't the JMS proxy then be setting a new JMSReplyTo on the message to
> one that it can remap?

It would be nice if it did but it's really more of a proxy look-alike and
there are technical reasons why it cannot modify the proxied messages. If
CXF cannot ignore the JMSReplyTo field, however, we have little choice but
to build our own "true" proxy to do just that.

Jens



--
View this message in context: http://cxf.547215.n5.nabble.com/JMS-Transport-Overriding-ReplyDestination-tp5731199p5731253.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: JMS Transport: Overriding ReplyDestination

Posted by Daniel Kulp <dk...@apache.org>.
On Jul 22, 2013, at 7:09 AM, Jens <sm...@dzbank.de> wrote:

> cschneider wrote
>> I don´t think this is possible at the moment. Can you explain your use 
>> case in detail?
> 
> In this case I receive the request via a JMS "proxy," and the original
> ReplyTo queue is inaccessible to my service. Instead I need to send the
> reply back to the proxy which will then forward it to the client (this could
> be done by keeping JMSReplyTo intact, I suppose, but we're using fixed
> queues anyway so that's unnecessary in this case; effectively, the client
> could also just not set JMSReplyTobut it's an external source and out of my
> control unfortunately).

Shouldn't the JMS proxy then be setting a new JMSReplyTo on the message to one that it can remap?


-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com


Re: JMS Transport: Overriding ReplyDestination

Posted by Jens <sm...@dzbank.de>.
cschneider wrote
> I don´t think this is possible at the moment. Can you explain your use 
> case in detail?

In this case I receive the request via a JMS "proxy," and the original
ReplyTo queue is inaccessible to my service. Instead I need to send the
reply back to the proxy which will then forward it to the client (this could
be done by keeping JMSReplyTo intact, I suppose, but we're using fixed
queues anyway so that's unnecessary in this case; effectively, the client
could also just not set JMSReplyTobut it's an external source and out of my
control unfortunately).

Jens



--
View this message in context: http://cxf.547215.n5.nabble.com/JMS-Transport-Overriding-ReplyDestination-tp5731199p5731212.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: JMS Transport: Overriding ReplyDestination

Posted by Christian Schneider <ch...@die-schneider.net>.
I don´t think this is possible at the moment. Can you explain your use 
case in detail?

The reason why the replyTo from the message is used is that the sender 
of the message knows where his reply queue is and will listen on it. So 
using any other
queue typically will not work. The only use case I can imagine is that 
you want some other service do some processing on the reply and only 
send it back to the original client after that. This case is difficult 
as the second service
would not know where to send the reply to as the original reply to of 
the message from the client would be lost.

Christian

Am 22.07.2013 10:37, schrieb Jens:
> Hi,
>
> is there a way to override the JMS ReplyDestination on the service
> implementor side even if the client sends the request with the JMSReplyTo
> field set? It looks like the destination from the message always takes
> precedence over the value from the JMSConfiguration but I need it the other
> way around. Something like "ignore JMSReplyTo" would work as well.
>
> Thanks,
> Jens
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/JMS-Transport-Overriding-ReplyDestination-tp5731199.html
> Sent from the cxf-user mailing list archive at Nabble.com.


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

Open Source Architect
Talend Application Integration Division http://www.talend.com