ubuntu-10.04.1-server-amd64
RabbitMQ 2.1.0, generic install
Java client: rabbitmq-java-client-bin-2.1.0
Java 1.5

The following code hangs on conn.close(). Specifying a timeout did not help. No issues when run on RabbitMQ 2.0.

--Steve

package com.bla.rabbit.test;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.MessageProperties;

public class Small {

/**
* @param args
*/
public static void main(String[] args) {

String exchange = "myexchangename";
String queue = "myqueuename";
String route = "myroutingkey";
String msg = "hello";
byte[] messageBodyBytes = msg.getBytes();

ConnectionFactory factory = new ConnectionFactory();
factory.setUsername("guest");
factory.setPassword("guest");
factory.setHost("127.0.0.1");
factory.setVirtualHost("test");

try {
Connection conn = factory.newConnection();
Channel pushChannel = conn.createChannel();

pushChannel.exchangeDeclare(exchange, "direct", true);
pushChannel.queueDeclare(queue, true, false, false, null);
pushChannel.queueBind(queue, exchange, route);

System.out.println("publish");
pushChannel.basicPublish(exchange, route, true, true, MessageProperties.PERSISTENT_TEXT_PLAIN, messageBodyBytes);

// we hang here
System.out.println("start close");
conn.close();
System.out.println("end close");
} catch (Exception ex) {
ex.printStackTrace();
}
}

}

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

Search Discussions

  • Matthias Radestock at Oct 14, 2010 at 9:42 pm
    Steve,

    Steve Haneman wrote:
    ubuntu-10.04.1-server-amd64
    RabbitMQ 2.1.0, generic install
    Java client: rabbitmq-java-client-bin-2.1.0
    Java 1.5

    The following code hangs on conn.close(). Specifying a timeout did not
    help. No issues when run on RabbitMQ 2.0.
    Is this reproducible? If so, please run the code you posted against the
    server with the protocol tracer
    (http://www.rabbitmq.com/examples.html#tracer) inbetween and post the
    output.
    System.out.println("publish");
    pushChannel.basicPublish(exchange, route, true,
    true, MessageProperties.PERSISTENT_TEXT_PLAIN, messageBodyBytes);
    // we hang here
    System.out.println("start close");
    conn.close();
    System.out.println("end close");
    So you do see the "start close" but not the "end close"?


    Regards,

    Matthias.
  • Steve Haneman at Oct 14, 2010 at 9:45 pm
    A restart of the server cleared it up. No errors in the rabbitmq logs. Seems fishy. I had been running some load tests on the server prior to it acting this way.

    --Steve

    From: Steve Haneman
    Sent: Thursday, October 14, 2010 2:13 PM
    To: rabbitmq-discuss at lists.rabbitmq.com
    Subject: connection.close() hangs

    ubuntu-10.04.1-server-amd64
    RabbitMQ 2.1.0, generic install
    Java client: rabbitmq-java-client-bin-2.1.0
    Java 1.5

    The following code hangs on conn.close(). Specifying a timeout did not help. No issues when run on RabbitMQ 2.0.

    --Steve

    package com.bla.rabbit.test;

    import com.rabbitmq.client.Channel;
    import com.rabbitmq.client.Connection;
    import com.rabbitmq.client.ConnectionFactory;
    import com.rabbitmq.client.MessageProperties;

    public class Small {

    /**
    * @param args
    */
    public static void main(String[] args) {

    String exchange = "myexchangename";
    String queue = "myqueuename";
    String route = "myroutingkey";
    String msg = "hello";
    byte[] messageBodyBytes = msg.getBytes();

    ConnectionFactory factory = new ConnectionFactory();
    factory.setUsername("guest");
    factory.setPassword("guest");
    factory.setHost("127.0.0.1");
    factory.setVirtualHost("test");

    try {
    Connection conn = factory.newConnection();
    Channel pushChannel = conn.createChannel();

    pushChannel.exchangeDeclare(exchange, "direct", true);
    pushChannel.queueDeclare(queue, true, false, false, null);
    pushChannel.queueBind(queue, exchange, route);

    System.out.println("publish");
    pushChannel.basicPublish(exchange, route, true, true, MessageProperties.PERSISTENT_TEXT_PLAIN, messageBodyBytes);

    // we hang here
    System.out.println("start close");
    conn.close();
    System.out.println("end close");
    } catch (Exception ex) {
    ex.printStackTrace();
    }
    }

    }

    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20101014/6dea1b4a/attachment-0001.htm>

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprabbitmq-discuss @
categoriesrabbitmq
postedOct 14, '10 at 9:13p
activeOct 14, '10 at 9:45p
posts3
users2
websiterabbitmq.com
irc#rabbitmq

People

Translate

site design / logo © 2023 Grokbase