Subscribing to a topic/subject using JMS 11.1 client

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Subscribing to a topic/subject using JMS 11.1 client

ncampbe
This post was updated on .
Hi all,

I am using JMS 11.1 (can't install java 8) and trying to subscribe to a specific subject under 'amq.topic' (broker is a QPID 1.36 C++ broker)

This works (except I get all messages sent to amq.topic):
TopicSubscriber sub = session.createSubscriber(session.createTopic("amq.topic"));

I have tried:
TopicSubscriber sub = session.createSubscriber(session.createTopic("amq.topic/someKey");
TopicSubscriber sub = session.createSubscriber(session.createTopic("topic://amq.topic?routingKey=someKey");
TopicSubscriber sub = session.createSubscriber(session.createTopic("amq.topic?routingKey=someKey");
I also tried numerous variations on this same theme that I have found online.  

Various older docs make it look like this SHOULD work (it does on C++ side for qpid::messaging::Address).

Everything I have tried causes an "amq:not-found" error on the broker.  The broker appears to be using the entire topic (i.e. "amq.topic/someKey") as the exchange, instead of exchange 'amq.topic' with subject/routingKey of 'someKey'.  Broker prints out "Error on attach: Node not found: amq.topic/someKey" (where Node matches topic I created).

I realize that I can use message selectors when I create the subscriber to filter the messages however that isn't an ideal solution for me for several reasons.  

Any suggestions on how I can get subject/routingKey filtering via JMS?

Thanks!

~nate
Reply | Threaded
Open this post in threaded view
|

Re: Subscribing to a topic/subject using JMS 11.1 client

Gordon Sim
On 07/06/17 23:51, ncampbe wrote:

> Hi all,
>
> I am using JMS 11.1 (can't install java 8) and trying to subscribe to a
> specific subject under 'amq.topic' (broker is a QPID 0.36 C++ broker)
>
> This works (except I get all messages sent to amq.topic):
> TopicSubscriber sub =
> session.createSubscriber(session.createTopic("amq.topic"));
>
> I have tried:
> TopicSubscriber sub =
> session.createSubscriber(session.createTopic("amq.topic/someKey");
> TopicSubscriber sub =
> session.createSubscriber(session.createTopic("topic://amq.topic?routingKey=someKey");
> TopicSubscriber sub =
> session.createSubscriber(session.createTopic("amq.topic?routingKey=someKey");
> (and numerous various on this same theme) that I have found online.
>
> Various older docs make it look like this SHOULD work (it does on C++ side
> for qpid::messaging::Address).
>
> Everything I have tried causes an "amq:not-found" error on the broker.  The
> broker appears to be using the entire topic (i.e. "amq.topic/someKey") as
> the exchange, instead of exchange 'amq.topic' with subject/routingKey of
> 'someKey'.  Broker prints out "Error on attach: Node not found:
> amq.topic/someKey" (where Node matches topic I created).
>
> I realize that I can use message selectors when I create the subscriber to
> filter the messages however that isn't an ideal solution for me for several
> reasons.
>
> Any suggestions on how I can get subject/routingKey filtering via JMS?

At present, the c++ broker only supports specifying the 'routing key'
(i.e. the pattern to match against the subject) via the 'legacy' filters
we defined:

 
https://github.com/apache/qpid/blob/trunk/qpid/specs/apache-filters.xml#L54

The qpid::messaging API will create an appropriate filter based on
node/subject (you can avoid that if needed by quoting), however other
clients/APIs will not.




---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Subscribing to a topic/subject using JMS 11.1 client

ncampbe
Gordon,

Thanks for the response.  It appears what I am trying to do isn't possible with JMS.

I will explore other options.

Thanks again,

~nate