[rabbitmq-discuss] Broken Pipe in RabbitMQ ConnectionFactory.newConnection()

John M. approche.pratique at gmail.com
Sun Sep 8 22:56:19 BST 2013


Michael,

Actually I am opening and closing connections quite a lot (once every ~3
RPC requests on average). Is that bad and I'm supposed to pool them?

The client code is (split into multiple methods actually, but roughly):

            factory = new ConnectionFactory();
           connection = factory.newConnection();
    channel = connection.createChannel();

    Map<String, Object> arguments = new HashMap<String, Object>();
    arguments.put("x-expires", 10*60*1000); // 10 min
replyQueueName = channel.queueDeclare("", false, true, true,
arguments).getQueue();

    consumer = new QueueingConsumer(channel);
    channel.basicConsume(replyQueueName, true, consumer);

            String response = null;
    String corrId = UUID.randomUUID().toString();

    BasicProperties props = new BasicProperties.Builder()
     .correlationId(corrId)
     .expiration(DEFAULT_TIMEOUT + "")
     .replyTo(replyQueueName)
     .build();

    channel.basicPublish("", queueName, props, message.getBytes());

                while (true) {
        QueueingConsumer.Delivery delivery = null;
try {
delivery = consumer.nextDelivery(100);
} catch (InterruptedException e) {}
 if (delivery == null) {
  continue;
}
        if (delivery.getProperties().getCorrelationId().equals(corrId)) {
            response = new String(delivery.getBody());

            break;
        } else {
         continue;
        }
    }

if (connection != null)
connection.abort(); // .close seemed to hang at
com.rabbitmq.client.impl.ChannelN.close(ChannelN.java:492) ->
com.rabbitmq.utility.BlockingCell.get(BlockingCell.java:50)




On Sun, Sep 8, 2013 at 9:11 PM, Michael Klishin <michael at rabbitmq.com>wrote:

> John M.:
>
> > I've reviewed the Rabbit logs and the only kind of errors I find there
> are:
> >
> >     =ERROR REPORT==== 6-Sep-2013::21:36:59 ===
> >     closing AMQP connection <0.3105.1297> (10.118.69.132:42582 ->
> 10.12.111.134:5672):
> >     {handshake_timeout,frame_header}
>
> John,
>
> Can you post a snippet of your code that demonstrates what operations lead
> [presumably] to this error? Is it possible that you are opening and
> closing connections
> constantly or only creating and deleting reply queues?
>
> MK
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20130908/54eb1872/attachment.htm>


More information about the rabbitmq-discuss mailing list