[rabbitmq-discuss] ReturnListener is not invoked

Dmitriy Bannikov dmitriy.bannikov at gmail.com
Thu Jan 17 23:04:23 GMT 2013


Hello,

I have a problem with ReturnListener - failed messages are not invoking it 
in Linux. 

Same code works fine in Windows.

I've created a test Java class which tries to publish message into a fake 
queue. 
In Windows this message is failing, and ReturnListener shows it's output. 
In Linux there're not error or fails.

I've just upgraded rabbitmq from 2.8.6 to 3.0.1 on both WIndows and Linux 
machines.

Code is following:

package my.test.rabbitmq;

import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.ReturnListener;

import java.io.IOException;

public class RabbitMQReturn
{

    public static void main(String[] args) throws Exception
    {
        ConnectionFactory factory = new ConnectionFactory();

        factory.setHost("localhost");
        factory.setUsername("testusr");
        factory.setPassword("testpwd");
        factory.setPort(5672);

        Connection connection = factory.newConnection();

        final Channel channel = connection.createChannel();

        channel.addReturnListener(new ReturnListener()
        {
            @Override
            public void handleReturn(int i, String s, String s2, String s3, 
AMQP.BasicProperties basicProperties,
                    byte[] bytes) throws IOException
            {
                System.err.println("Sending failed: " + s + " [" + i + "]");
            }
        });

        AMQP.BasicProperties props = new 
AMQP.BasicProperties("application/octet-stream",
                null,
                null,
                2,
                0, null, null, null,
                null, null, null, null,
                null, null);

        channel.basicPublish("", "fake_queue_112233", true, true, props, 
"Test String".getBytes());
    }
}


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20130117/b511b0b8/attachment.htm>


More information about the rabbitmq-discuss mailing list