You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by boekhold <bo...@gmx.com> on 2017/10/02 10:14:58 UTC

msg.getJMSReplyTo().toString() and Session.createQueue(replyString)

Hi,

The following code fails:

String replyDestStr = msg.getJMSReplyTo().toString();
// forward the request asynchronously to a 3rd-party system, with
// "replyDestStr" included in the 3rd-party request and response
Queue replyQ = session.createQueue(replyDestStr);

The problem is that the first line returns something like
"queue://queuename", but the createQueue() call doesn't strip that off, and
I end up posting to a queue that is *actually* called "queue://queuename".

Which is a bit weird, because ActiveMQDestination.createDestination(name)
*does* strip off the qualified prefixes.

Unfortunately I cannot use the ActiveMQDestination.createDestination() call
because my code has to be generic (specifically it has to work with
WebsphereMQ as well).

Is this a bug perhaps? Maybe ActiveMQSession.createQueue() shouldn't call
"new ActiveMQQueue()", but "ActiveMQDestination.createDestination(name, 1)"?

Maarten



--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html

Re: msg.getJMSReplyTo().toString() and Session.createQueue(replyString)

Posted by boekhold <bo...@gmx.com>.
Mea culpa,

that code should be:

String replyDestStr = msg.getJMSReplyTo().getQueueName();
// forward the request asynchronously to a 3rd-party system, with
// "replyDestStr" included in the 3rd-party request and response
Queue replyQ = session.createQueue(replyDestStr); 

Code tested so far with ActiveMQ and TIBCO EMS. I expect it will work on
WebsphereMQ as well (com.ibm.mq.jms.MQQueue.getQueueName() seems to return
the expected "queue://queuename/qmgrname" format).

Maarten



--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html

Re: msg.getJMSReplyTo().toString() and Session.createQueue(replyString)

Posted by Justin Bertram <jb...@apache.org>.
Couple of things...

  1) I believe Tim is right that you might need to munge the queue name a
bit yourself to deal with portability issues.  Of
javax.jms.Session#createQueue, the JavaDoc says, "This facility is provided
for the rare cases where clients need to dynamically manipulate queue
identity. It allows the creation of a queue identity with a
provider-specific name. Clients that depend on this ability are not
portable."  Also, the JavaDoc says this about javax.jms.Queue#getQueueName,
"Clients that depend upon the name are not portable."

  2) I'm guessing the code you pasted previously won't actually compile as
javax.jms.Message#getJMSReplyTo returns a javax.jms.Destination which
doesn't have a getQueueName method.

  3) Since javax.jms.Message#getJMSReplyTo returns a javax.jms.Destination
why not just use that instead of using the String as a middleman to create
a javax.jms.Queue?


Justin

On Mon, Oct 2, 2017 at 1:46 PM, Tim Bain <tb...@alumni.duke.edu> wrote:

> Session.createQueue() is defined as part of the JMS spec, and it's not a
> bug when it doesn't do things beyond the requirements of the spec.
>
> Just strip off the prefix yourself before you call it.
>
> Tim
>
> On Oct 2, 2017 5:15 AM, "boekhold" <bo...@gmx.com> wrote:
>
> Hi,
>
> The following code fails:
>
> String replyDestStr = msg.getJMSReplyTo().toString();
> // forward the request asynchronously to a 3rd-party system, with
> // "replyDestStr" included in the 3rd-party request and response
> Queue replyQ = session.createQueue(replyDestStr);
>
> The problem is that the first line returns something like
> "queue://queuename", but the createQueue() call doesn't strip that off, and
> I end up posting to a queue that is *actually* called "queue://queuename".
>
> Which is a bit weird, because ActiveMQDestination.createDestination(name)
> *does* strip off the qualified prefixes.
>
> Unfortunately I cannot use the ActiveMQDestination.createDestination()
> call
> because my code has to be generic (specifically it has to work with
> WebsphereMQ as well).
>
> Is this a bug perhaps? Maybe ActiveMQSession.createQueue() shouldn't call
> "new ActiveMQQueue()", but "ActiveMQDestination.createDestination(name,
> 1)"?
>
> Maarten
>
>
>
> --
> Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-
> f2341805.html
>

Re: msg.getJMSReplyTo().toString() and Session.createQueue(replyString)

Posted by Tim Bain <tb...@alumni.duke.edu>.
Session.createQueue() is defined as part of the JMS spec, and it's not a
bug when it doesn't do things beyond the requirements of the spec.

Just strip off the prefix yourself before you call it.

Tim

On Oct 2, 2017 5:15 AM, "boekhold" <bo...@gmx.com> wrote:

Hi,

The following code fails:

String replyDestStr = msg.getJMSReplyTo().toString();
// forward the request asynchronously to a 3rd-party system, with
// "replyDestStr" included in the 3rd-party request and response
Queue replyQ = session.createQueue(replyDestStr);

The problem is that the first line returns something like
"queue://queuename", but the createQueue() call doesn't strip that off, and
I end up posting to a queue that is *actually* called "queue://queuename".

Which is a bit weird, because ActiveMQDestination.createDestination(name)
*does* strip off the qualified prefixes.

Unfortunately I cannot use the ActiveMQDestination.createDestination() call
because my code has to be generic (specifically it has to work with
WebsphereMQ as well).

Is this a bug perhaps? Maybe ActiveMQSession.createQueue() shouldn't call
"new ActiveMQQueue()", but "ActiveMQDestination.createDestination(name, 1)"?

Maarten



--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html