You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by helicopterman22 <he...@btinternet.com> on 2015/10/23 23:26:28 UTC

java jms client 0.28 destination help

I am using the Java JMS client (0.28) to connect to a AMQP brokers (Java and
C++)

In my receiver I have the following destination string which creates a
headers queue and binds to the exchange without any problem.

myapp_queue;{create:receiver,delete:always,node:{type:queue,x-bindings:[{exchange:'amq.match',arguments:{x-match:all,name:'dave'}}]}}

However I think my senders should only need to know the exchange and the
headers details to send messages to my exchange. I cannot workout the syntax
to send to the headers exchange using my header. I have the following:

exchange:'amq.match',arguments:{x-match:all,name:'dave'}


...but I get a JMS connection exception can anyone help please?



--
View this message in context: http://qpid.2158936.n2.nabble.com/java-jms-client-0-28-destination-help-tp7632825.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: java jms client 0.28 destination help

Posted by Robbie Gemmell <ro...@gmail.com>.
On 24 October 2015 at 16:25, helicopterman22
<he...@btinternet.com> wrote:
> Hi
>
> No, I was hoping that the headers that go with the message that the exchange
> will use to decide which queue to put the message on could be part of the
> destination string.
>
> Such as       (exchange name) (delimiter) (headers)     for example.
>
> I can use the destination string to publish and subscribe to other types of
> exchanges, it would be a bit of a nuisance if I have to create separate
> classes to cope with publishing to a headers exchange.
>
> As I said the documentation hints that I can do this but only gives examples
> for queues and topics.
>

The headers that the exchange uses to filter the messages onto its
bound queues are part of the messages sent rather than the destination
(which in this case would simply be the exchange itself), so you dont
include them in the destination string of the producer. Instead you
set the headers on the individual messages that you send; you
potentially might set different headers on every message such that
they might match different bindings. The headers are mentioned in the
destination string for the consumer because that is how you have
configured the exchange binding the consumer adds to say which headers
you want it to filter to the queue being bound to the exchange.

If you want the desitnation string itself to so closely govern where
the messages go when sent, you might be better using something other
than a headers exchange.

Robbie

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: java jms client 0.28 destination help

Posted by helicopterman22 <he...@btinternet.com>.
Hi

No, I was hoping that the headers that go with the message that the exchange
will use to decide which queue to put the message on could be part of the
destination string.

Such as       (exchange name) (delimiter) (headers)     for example.

I can use the destination string to publish and subscribe to other types of
exchanges, it would be a bit of a nuisance if I have to create separate
classes to cope with publishing to a headers exchange.

As I said the documentation hints that I can do this but only gives examples
for queues and topics.





--
View this message in context: http://qpid.2158936.n2.nabble.com/java-jms-client-0-28-destination-help-tp7632825p7632832.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: java jms client 0.28 destination help

Posted by Rob Godfrey <ro...@gmail.com>.
In what way is "amq.match/" not a destination string?  Are you wishing to
enforce extra constraints (such as the creation and binding of the queue)
at the point of creating the producer.

-- Rob

On 24 October 2015 at 09:49, helicopterman22 <helicopterman22@btinternet.com
> wrote:

> Hi,
>
> Thanks for the reply, it sort of helps, I was hoping there was
> 'destination'
> string in the same sort of format as my receiver destination string. I want
> to give the sender a string to put into their interface which can then be
> passed to my java code.
> The jms code implies this can be done but gives no examples with header
> exchanges.
>
> Thanks
> Dave
>
>
>
> --
> View this message in context:
> http://qpid.2158936.n2.nabble.com/java-jms-client-0-28-destination-help-tp7632825p7632830.html
> Sent from the Apache Qpid users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> For additional commands, e-mail: users-help@qpid.apache.org
>
>

Re: java jms client 0.28 destination help

Posted by helicopterman22 <he...@btinternet.com>.
Hi,

Thanks for the reply, it sort of helps, I was hoping there was 'destination'
string in the same sort of format as my receiver destination string. I want
to give the sender a string to put into their interface which can then be
passed to my java code.
The jms code implies this can be done but gives no examples with header
exchanges.

Thanks
Dave



--
View this message in context: http://qpid.2158936.n2.nabble.com/java-jms-client-0-28-destination-help-tp7632825p7632830.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: java jms client 0.28 destination help

Posted by Rob Godfrey <ro...@gmail.com>.
There are others who are more expert on the addressing syntax, but the
following works for me:

connection.start();

// set up consumer
Session consumerSession = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
Queue queue =
consumerSession.createQueue("myapp_queue;{create:receiver,delete:always,node:{type:queue,x-bindings:[{exchange:'amq.match',arguments:{x-match:all,name:'dave'}}]}}");
final MessageConsumer consumer = consumerSession.createConsumer(queue);

// set up producer
Session producerSession = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
Topic topic = producerSession.createTopic("amq.match/");
final MessageProducer producer = producerSession.createProducer(topic);

// create and send the message with the appropriately set header property
TextMessage message = producerSession.createTextMessage("Hello world");
message.setStringProperty("name", "dave");
producer.send(message);

// receive the message
Message received = consumer.receive(1000l);
System.out.println(((TextMessage)received).getText());

Hope this helps,
Rob

On 23 October 2015 at 22:26, helicopterman22 <helicopterman22@btinternet.com
> wrote:

> I am using the Java JMS client (0.28) to connect to a AMQP brokers (Java
> and
> C++)
>
> In my receiver I have the following destination string which creates a
> headers queue and binds to the exchange without any problem.
>
>
> myapp_queue;{create:receiver,delete:always,node:{type:queue,x-bindings:[{exchange:'amq.match',arguments:{x-match:all,name:'dave'}}]}}
>
> However I think my senders should only need to know the exchange and the
> headers details to send messages to my exchange. I cannot workout the
> syntax
> to send to the headers exchange using my header. I have the following:
>
> exchange:'amq.match',arguments:{x-match:all,name:'dave'}
>
>
> ...but I get a JMS connection exception can anyone help please?
>
>
>
> --
> View this message in context:
> http://qpid.2158936.n2.nabble.com/java-jms-client-0-28-destination-help-tp7632825.html
> Sent from the Apache Qpid users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> For additional commands, e-mail: users-help@qpid.apache.org
>
>