You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by fadams <fr...@blueyonder.co.uk> on 2011/06/18 17:44:40 UTC

how do I retrieve the subject from JMS?

Hello,
can anyone tell me how to retrieve a message's subject.

I've tried

System.out.println(message.getStringProperty("qpid.subject"));

to check but that just returns a null string

Funnily enough if I Google getStringProperty("qpid.subject") I get nothing,
but if I Google setStringProperty("qpid.subject") it returns links to some
code for some test cases, so it looks just about the right way to go but
it's weird that theres links for setting, but not getting - which makes me a
bit suspicious.

Any ideas??

--
View this message in context: http://apache-qpid-users.2158936.n2.nabble.com/how-do-I-retrieve-the-subject-from-JMS-tp6491033p6491033.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: how do I retrieve the subject from JMS?

Posted by fadams <fr...@blueyonder.co.uk>.
Soooo is there any "good" reason for not making x-amqp-0-10.routing-key
available for JMS clients.

Doing some Googling on this apparently it used to be available (though
returned a byte[] not a string) but it got removed as it wasn't a standard
JMS property.

I can't see any reason why it's not made available - it's really useful for
demultiplexing topics if one subscribes to a wildcard, for example to
implement client side custom filters.

Theres an evil hack that can be used by regexing the "toString" form of
getJMSDestination() :-D but it really pains me to have to do that and
clearly it could be broken on any new release.

If it's good enough for the C++ and python APIs it's good enough for Java.

Regards,
Frase



Gordon Sim wrote:
> 
> On 06/24/2011 05:13 PM, Rajith Attapattu wrote:
>> Unfortunately the JMS client doesn't put the routing key in message
>> properties when sending messages.
>> However I believe the C++ client includes a property called
>> ""x-amqp-0-10.routing-key"
>> I checked with the C++ version of spout but it didn't seem that
>> property was used.
> 
> It's only used for reading the routing key of a received message (you 
> can control the routing key for messages you sent through the address 
> name or subject (depending on node type).
>>
>> Rajith
>>
> 
> 


--
View this message in context: http://apache-qpid-users.2158936.n2.nabble.com/how-do-I-retrieve-the-subject-from-JMS-tp6491033p6611531.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: how do I retrieve the subject from JMS?

Posted by Gordon Sim <gs...@redhat.com>.
On 06/24/2011 05:13 PM, Rajith Attapattu wrote:
> Unfortunately the JMS client doesn't put the routing key in message
> properties when sending messages.
> However I believe the C++ client includes a property called
> ""x-amqp-0-10.routing-key"
> I checked with the C++ version of spout but it didn't seem that
> property was used.

It's only used for reading the routing key of a received message (you 
can control the routing key for messages you sent through the address 
name or subject (depending on node type).

> I came across this property when fixing QPID-2930, but can't remember
> the exact circumstances under which this property was set.
>
> Perhaps Gordon can comment more on this.
>
> Rajith
>
> On Fri, Jun 24, 2011 at 11:13 AM, fadams<fr...@blueyonder.co.uk>  wrote:
>> So guys, if the subject isn't what I actually need is it possible to retrieve
>> the routing key in (JMS) client code?
>>
>> It's kind of useful to be able to "probe" subjects/routing-keys to see
>> what's being published so one can refine a particular subscription.
>>
>> Or maybe I'm just weird :-)
>>
>>
>> Gordon Sim wrote:
>>>
>>>
>>> It is a little confusing. The concept of subject doesn't actually exist
>>> in AMQP 0-10. There is the concept of a routing-key which is in many
>>> ways like a subject
>>>
>>>
>>
>>
>> --
>> View this message in context: http://apache-qpid-users.2158936.n2.nabble.com/how-do-I-retrieve-the-subject-from-JMS-tp6491033p6512361.html
>> Sent from the Apache Qpid users mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> Apache Qpid - AMQP Messaging Implementation
>> Project:      http://qpid.apache.org
>> Use/Interact: mailto:users-subscribe@qpid.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> Apache Qpid - AMQP Messaging Implementation
> Project:      http://qpid.apache.org
> Use/Interact: mailto:users-subscribe@qpid.apache.org
>
>
>


---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: how do I retrieve the subject from JMS?

Posted by Rajith Attapattu <ra...@gmail.com>.
Unfortunately the JMS client doesn't put the routing key in message
properties when sending messages.
However I believe the C++ client includes a property called
""x-amqp-0-10.routing-key"
I checked with the C++ version of spout but it didn't seem that
property was used.
I came across this property when fixing QPID-2930, but can't remember
the exact circumstances under which this property was set.

Perhaps Gordon can comment more on this.

Rajith

On Fri, Jun 24, 2011 at 11:13 AM, fadams <fr...@blueyonder.co.uk> wrote:
> So guys, if the subject isn't what I actually need is it possible to retrieve
> the routing key in (JMS) client code?
>
> It's kind of useful to be able to "probe" subjects/routing-keys to see
> what's being published so one can refine a particular subscription.
>
> Or maybe I'm just weird :-)
>
>
> Gordon Sim wrote:
>>
>>
>> It is a little confusing. The concept of subject doesn't actually exist
>> in AMQP 0-10. There is the concept of a routing-key which is in many
>> ways like a subject
>>
>>
>
>
> --
> View this message in context: http://apache-qpid-users.2158936.n2.nabble.com/how-do-I-retrieve-the-subject-from-JMS-tp6491033p6512361.html
> Sent from the Apache Qpid users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> Apache Qpid - AMQP Messaging Implementation
> Project:      http://qpid.apache.org
> Use/Interact: mailto:users-subscribe@qpid.apache.org
>
>

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: how do I retrieve the subject from JMS?

Posted by fadams <fr...@blueyonder.co.uk>.
So guys, if the subject isn't what I actually need is it possible to retrieve
the routing key in (JMS) client code?

It's kind of useful to be able to "probe" subjects/routing-keys to see
what's being published so one can refine a particular subscription.

Or maybe I'm just weird :-)


Gordon Sim wrote:
> 
> 
> It is a little confusing. The concept of subject doesn't actually exist 
> in AMQP 0-10. There is the concept of a routing-key which is in many 
> ways like a subject
> 
> 


--
View this message in context: http://apache-qpid-users.2158936.n2.nabble.com/how-do-I-retrieve-the-subject-from-JMS-tp6491033p6512361.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: how do I retrieve the subject from JMS?

Posted by Gordon Sim <gs...@redhat.com>.
On 06/24/2011 03:05 PM, fadams wrote:
> I'm a bit confused.
> Surely the subject has to have been set *somewhere* by the producer, after
> all I'm successfully subscribing to
> "qmf.default.topic/agent.ind.event.org_apache_qpid_broker.#" so the topic
> exchange would be using the subject to apply the binding.
>
> have I missed something???

It is a little confusing. The concept of subject doesn't actually exist 
in AMQP 0-10. There is the concept of a routing-key which is in many 
ways like a subject, especially when using topics. However the exact 
correspondence breaks down a little for queues. Hence we introduced a 
qpid specific variable through which a subject could be carried in a 
message.

So in your case the subscription is being mapped to a binding using a 
particular binding key. Messages received over that binding will have 
the routing key set, but in this case they don't have that special 
subject property set.

We could in these cases (i.e. where there is no qpid.subject) fall back 
to returning the routing key. That might make things less confusing (or 
possibly more?!).

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: how do I retrieve the subject from JMS?

Posted by Rajith Attapattu <ra...@gmail.com>.
The exchange (broker) does not use the subject at all for it's routing
 as it's not there in AMQP 0-10 (the protocol uses routing key for
this).
The subject was introduced by the new addressing mechanism and is Qpid
specific.
(I believe in AMQP 1.0 the subject is in the protocol itself and
qpid.subject will map directly to that - however I stand to be
corrected).

But for now "qpid.subject" remains a Qpid specific property used by
the new Qpid Client API (and also JMS).
The doc sort of explains how the qpid.subject maps to the AMQP 0-10
protocol - perhaps that section is not clear enough?

Regards,

Rajith

On Fri, Jun 24, 2011 at 10:05 AM, fadams <fr...@blueyonder.co.uk> wrote:
> I'm a bit confused.
> Surely the subject has to have been set *somewhere* by the producer, after
> all I'm successfully subscribing to
> "qmf.default.topic/agent.ind.event.org_apache_qpid_broker.#" so the topic
> exchange would be using the subject to apply the binding.
>
> have I missed something???
>
>
> Rajith Attapattu wrote:
>>
>> Fraser,
>>
>> The client who is sending the message (in this case the QMF component
>> in the broker) is responsible for setting the subject.
>> If receiver side merely retrieves it from the application headers if
>> it's present.
>> So it looks like QMF side is not sending it.
>>
>> I copied Ted on this, as he may be able to give a more definitive
>> answer on that.
>>
>> Regards,
>>
>> Rajith
>>
>>
>
>
> --
> View this message in context: http://apache-qpid-users.2158936.n2.nabble.com/how-do-I-retrieve-the-subject-from-JMS-tp6491033p6512099.html
> Sent from the Apache Qpid users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> Apache Qpid - AMQP Messaging Implementation
> Project:      http://qpid.apache.org
> Use/Interact: mailto:users-subscribe@qpid.apache.org
>
>

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: how do I retrieve the subject from JMS?

Posted by fadams <fr...@blueyonder.co.uk>.
I'm a bit confused.
Surely the subject has to have been set *somewhere* by the producer, after
all I'm successfully subscribing to
"qmf.default.topic/agent.ind.event.org_apache_qpid_broker.#" so the topic
exchange would be using the subject to apply the binding.

have I missed something???


Rajith Attapattu wrote:
> 
> Fraser,
> 
> The client who is sending the message (in this case the QMF component
> in the broker) is responsible for setting the subject.
> If receiver side merely retrieves it from the application headers if
> it's present.
> So it looks like QMF side is not sending it.
> 
> I copied Ted on this, as he may be able to give a more definitive
> answer on that.
> 
> Regards,
> 
> Rajith
> 
> 


--
View this message in context: http://apache-qpid-users.2158936.n2.nabble.com/how-do-I-retrieve-the-subject-from-JMS-tp6491033p6512099.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: how do I retrieve the subject from JMS?

Posted by Rajith Attapattu <ra...@gmail.com>.
Fraser,

The client who is sending the message (in this case the QMF component
in the broker) is responsible for setting the subject.
If receiver side merely retrieves it from the application headers if
it's present.
So it looks like QMF side is not sending it.

I copied Ted on this, as he may be able to give a more definitive
answer on that.

Regards,

Rajith

On Fri, Jun 24, 2011 at 3:03 AM, fadams <fr...@blueyonder.co.uk> wrote:
> Hi Rajith
>
> I'm using qpid 0.8 (c++ broker)
>
> Re: "What is the address string you are using on the producer side". That's
> more interesting, what I am /actually/ doing is subscribing to
> "qmf.default.topic/agent.ind.event.org_apache_qpid_broker.#" - see the "Is
> it possible to write a client that gets notified of
> connections/disconnections to broker? " thread - I got that subject from
> Gordon Sim.
>
> Anyway what I was trying to do was to simply display the complete subject -
> I was ultimately going to subscribe to qmf.default.topic/# so I could
> identify the whole range of subjects being published in order to understand
> a bit more about some of the management messages.
>
> Like I say though I've not had any luck with
> getStringProperty("qpid.subject") it seems to return null
>
> Any thoughts?
> Fraser
>
>
> Rajith Attapattu wrote:
>>
>> Hi,
>>
>> I just checked with test program and I can retrieve the subject using
>> msg.getStringProperty("qpid.subject").
>> Which qpid release are you using ?
>> What is the address string you are using on the producer side ?
>>
>> Regards,
>>
>> Rajith
>>
>> ---------------------------------------------------------------------
>> Apache Qpid - AMQP Messaging Implementation
>> Project:      http://qpid.apache.org
>> Use/Interact: mailto:users-subscribe@qpid.apache.org
>>
>
>
> --
> View this message in context: http://apache-qpid-users.2158936.n2.nabble.com/how-do-I-retrieve-the-subject-from-JMS-tp6491033p6511087.html
> Sent from the Apache Qpid users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> Apache Qpid - AMQP Messaging Implementation
> Project:      http://qpid.apache.org
> Use/Interact: mailto:users-subscribe@qpid.apache.org
>
>

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: how do I retrieve the subject from JMS?

Posted by fadams <fr...@blueyonder.co.uk>.
Hi Rajith

I'm using qpid 0.8 (c++ broker)

Re: "What is the address string you are using on the producer side". That's
more interesting, what I am /actually/ doing is subscribing to
"qmf.default.topic/agent.ind.event.org_apache_qpid_broker.#" - see the "Is
it possible to write a client that gets notified of
connections/disconnections to broker? " thread - I got that subject from
Gordon Sim.

Anyway what I was trying to do was to simply display the complete subject -
I was ultimately going to subscribe to qmf.default.topic/# so I could
identify the whole range of subjects being published in order to understand
a bit more about some of the management messages.

Like I say though I've not had any luck with
getStringProperty("qpid.subject") it seems to return null

Any thoughts?
Fraser


Rajith Attapattu wrote:
> 
> Hi,
> 
> I just checked with test program and I can retrieve the subject using
> msg.getStringProperty("qpid.subject").
> Which qpid release are you using ?
> What is the address string you are using on the producer side ?
> 
> Regards,
> 
> Rajith
> 
> ---------------------------------------------------------------------
> Apache Qpid - AMQP Messaging Implementation
> Project:      http://qpid.apache.org
> Use/Interact: mailto:users-subscribe@qpid.apache.org
> 


--
View this message in context: http://apache-qpid-users.2158936.n2.nabble.com/how-do-I-retrieve-the-subject-from-JMS-tp6491033p6511087.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: how do I retrieve the subject from JMS?

Posted by Rajith Attapattu <ra...@gmail.com>.
Hi,

I just checked with test program and I can retrieve the subject using
msg.getStringProperty("qpid.subject").
Which qpid release are you using ?
What is the address string you are using on the producer side ?

Regards,

Rajith

On Sat, Jun 18, 2011 at 11:44 AM, fadams <fr...@blueyonder.co.uk> wrote:
> Hello,
> can anyone tell me how to retrieve a message's subject.
>
> I've tried
>
> System.out.println(message.getStringProperty("qpid.subject"));
>
> to check but that just returns a null string
>
> Funnily enough if I Google getStringProperty("qpid.subject") I get nothing,
> but if I Google setStringProperty("qpid.subject") it returns links to some
> code for some test cases, so it looks just about the right way to go but
> it's weird that theres links for setting, but not getting - which makes me a
> bit suspicious.
>
> Any ideas??
>
> --
> View this message in context: http://apache-qpid-users.2158936.n2.nabble.com/how-do-I-retrieve-the-subject-from-JMS-tp6491033p6491033.html
> Sent from the Apache Qpid users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> Apache Qpid - AMQP Messaging Implementation
> Project:      http://qpid.apache.org
> Use/Interact: mailto:users-subscribe@qpid.apache.org
>
>

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org