On 11/23/2012 01:38 PM, eugene wrote:
Hello,
I am trying to use the x-bindings property and I just can't. :(
Here is my case scenario:
Here is the producer:
String ALTERNATE_EXCHANGE = "amq.topic";
String producerQueue ="producerQ; {create:always,
node:{x-declare:{auto-delete:true, exclusive:true, alternate-exchange:
'"+ALTERNATE_EXCHANGE+"'}}}"; // +
Session session = createSession();
MessageProducer producer =
session.createProducer(session.createQueue(requestsQueue));
^^^ this should be producerQueue, right?
TextMessage message = session.createTextMessage("Some Payload");
producerDirect.send(message);
Thread.sleep(10 * 1000);
So, while this is running (Thread.sleep), I stop it. What this means is that
the message that is in the producerQ will get orphaned and because of the
alternate-exchange presence will get routed to the amq.topic exchange. This
is pretty clear to me.
Now the second part, before starting the code above, I start this one:
Session session = createSession();
Queue receiverQ = session.createQueue("receiverQ; {create: receiver,
node:{x-bindings:[{exchange:'amq.topic', key:'producerQ',
queue:'receiverQ'}]}} ");
MessageConsumer consumer = session.createConsumer(receiverQ);
consumer.setMessageListener(new TestListener());
while(true){}
private static final class TestListener implements MessageListener {
@Override
public void onMessage(Message message) {
System.out.println("================ received");
try {
AMQDestination destination =
(AMQDestination)message.getJMSDestination();
System.out.println("============= " +
destination.getRoutingKey());
} catch (JMSException e) {
e.printStackTrace();
}
}
}
Now I assume that because of the x-bindings declaration, the messages that
end in the amq.topic exchange and have the routing key set to : "producerQ"
will end in my receiverQ that I have a listener on.
But (otherwise I would not write this), no message gets into my listener.
I think that there is something wrong with the declaration of x-bindings,
but I am not sure.
It looks ok to me (I myself would probably go for
session.createTopic("amq.topic/producerQ"), but that is likely a matter
of preference only).
Just to check - you did call Connection.start, right? Can you send me
the broker log for this case and I can see if anything obvious leaps out...
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@qpid.apache.org
For additional commands, e-mail: dev-h...@qpid.apache.org