Hello,

So here is my pretty much simple scenario. I want to take advantage of the
orphaned messages and the alternate exchange. From what I read, if a message
ends up in a queue and that queue get's deleted (but it has an alternate
exchange declared), the queue will indeed get deleted, but the messages
present in it will get re-directed to the alternate exchange. 1) Right?

2) The scenario I have is pretty much complicated, but put is simple is
this:

A producer flow:

private static final String ALTERNATE_EXCHANGE = "amq.topic";

Connection connection = connectionFactory.createConnection();
                Session session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
                Queue testQueue = session.createQueue("TEST_QUEUE; 
{create:always,
node:{x-declare:{auto-delete:true, exclusive: true, alternate-exchange:
'"+ALTERNATE_EXCHANGE+"'}}}");
                
                System.out.println("Will send message to : " + 
testQueue.toString());
                
                MessageProducer producer = session.createProducer(testQueue);
                TextMessage message      = session.createTextMessage("Some 
value");
                producer.send(message);

Notice the auto-delete true, if producer.send(message) is the last line of
my code - and indeed it is, then immediately after it, the queue TEST_QUEUE
will be deleted and the message routed to the amq.topic exchange. If only I
had a listener on that exchange...

And I do have one:

Connection connection = connectionFactory.createConnection();
                Session session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
                
                Thread thread = new Thread(new MyRunnable(session));
                thread.start();
        }
        
        private static final class MyRunnable implements Runnable {
                
                private final Session session;
                
                public MyRunnable(Session session){
                        this.session = session;
                }
                
                public void run(){
                        try {
                                MessageConsumer consumer =
session.createConsumer(session.createQueue("amq.topic"));
                                consumer.setMessageListener(new 
MyMessageListener());
                                
                                //Should be a flag here, but ignore for now
                                while(true){}
                        } catch (JMSException e) {
                                e.printStackTrace();
                        }
                }
        }
        
        private static final class MyMessageListener implements MessageListener 
{
                public void onMessage(Message message){
                        System.out.println("Message Received");
                        if(message instanceof TextMessage) {
                                try {
                                        System.out.println("Payload : " + 
((TextMessage)message).getText());
                                } catch (JMSException e) {
                                        e.printStackTrace();
                                }
                        }
                }
        }

But not a single message hits my listener. :( 
So does this sound like a bug or something stupid that I did not get right?

Thank You,
Eugene.



--
View this message in context: 
http://apache-qpid-developers.2158895.n2.nabble.com/Alternate-Exchange-with-auto-delete-queue-tp7583361.html
Sent from the Apache Qpid developers mailing list archive at Nabble.com.

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

Reply via email to