Discussion:
[rabbitmq-users] Channel closed after BasicACK
r***@meltwater.com
2015-03-09 15:00:16 UTC
Permalink
I have a basic consumer, on the handleDelivery i send basicAck and on the
next messaged an get an error saying that that channel is closed, how can i
fix this? probably i'm using the Consumers the wrong way.

thanks.
--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+***@googlegroups.com.
To post to this group, send an email to rabbitmq-***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Alvaro Videla
2015-03-09 15:04:04 UTC
Permalink
Is better to post some sample code and perhaps error logs from the server.
The error received at the client side would also be helpful.

Nonetheless, usually when a channel is closed due to a basicAck it might
mean that your app is sending the wrong delivery_tag back to the server.
Are you perhaps sharing channels across threads?
Post by r***@meltwater.com
I have a basic consumer, on the handleDelivery i send basicAck and on the
next messaged an get an error saying that that channel is closed, how can i
fix this? probably i'm using the Consumers the wrong way.
thanks.
--
You received this message because you are subscribed to the Google Groups
"rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+***@googlegroups.com.
To post to this group, send an email to rabbitmq-***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
r***@meltwater.com
2015-03-09 15:08:35 UTC
Permalink
this is my class consumer:









package com.company.masf.search.consumer;



import java.io.IOException;



import org.apache.commons.logging.Log;

import org.apache.commons.logging.LogFactory;




import com.rabbitmq.client.AMQP;

import com.rabbitmq.client.Channel;

import com.rabbitmq.client.Envelope;

import com.rabbitmq.client.QueueingConsumer;

import com.rabbitmq.client.ShutdownSignalException;

import com.rabbitmq.client.impl.LongStringHelper;



public class DeleteSearchConsumer extends QueueingConsumer {

Log LOG = LogFactory.getLog(DeleteSearchConsumer.class);



public DeleteSearchConsumer(Channel channel) {

super(channel);

}



@Override

public void handleDelivery(java.lang.String consumerTag,

Envelope envelope,

AMQP.BasicProperties properties,

byte[] body) throws IOException {

LOG.info("We got a message: "+ body.toString());



SavedSearch search = null;

Channel channel = getChannel();

Long savedSearchId = getSavedSearchLong(body);



LOG.info("properties" + properties);

LOG.info("body" + body);



channel.basicAck(envelope.getDeliveryTag(), false);





}



@Override

public void handleShutdownSignal(java.lang.String consumerTag,

ShutdownSignalException sig) {

LOG.info("Channel closed", sig);

}



private Long getSavedSearchLong(byte[] searchId) {

String searchIdLongString = LongStringHelper.asLongString(
searchId).toString();

Long searchIdLong = Long.parseLong(searchIdLongString);




return searchIdLong;

}

}

and this is the error:

2015-03-09 10:30:35 DeleteSearchConsumer [INFO ] [pool-2-thread-9]: body[
***@5ccd5dc2

com.rabbitmq.client.AlreadyClosedException: channel is already closed due
to channel error; protocol method: #method<channel.close>(reply-code=406,
reply-text=PRECONDITION_FAILED - unknown delivery tag 1, class-id=60,
method-id=80)

at com.rabbitmq.client.impl.AMQChannel.ensureIsOpen(AMQChannel.java:
190)

at com.rabbitmq.client.impl.AMQChannel.transmit(AMQChannel.java:291)

at com.rabbitmq.client.impl.AMQChannel.transmit(AMQChannel.java:285)

at com.rabbitmq.client.impl.ChannelN.basicAck(ChannelN.java:1012)

at com.bla.masf.search.consumer.DeleteSearchConsumer.handleDelivery(
DeleteSearchConsumer.java:37)

at com.rabbitmq.client.impl.ConsumerDispatcher$5.run(
ConsumerDispatcher.java:144)

at com.rabbitmq.client.impl.ConsumerWorkService$WorkPoolRunnable.run
(ConsumerWorkService.java:95)

at java.util.concurrent.ThreadPoolExecutor.runWorker(
ThreadPoolExecutor.java:1145)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(
ThreadPoolExecutor.java:615)

at java.lang.Thread.run(Thread.java:745)
Post by Alvaro Videla
Is better to post some sample code and perhaps error logs from the server.
The error received at the client side would also be helpful.
Nonetheless, usually when a channel is closed due to a basicAck it might
mean that your app is sending the wrong delivery_tag back to the server.
Are you perhaps sharing channels across threads?
Post by r***@meltwater.com
I have a basic consumer, on the handleDelivery i send basicAck and on
the next messaged an get an error saying that that channel is closed, how
can i fix this? probably i'm using the Consumers the wrong way.
thanks.
--
You received this message because you are subscribed to the Google Groups
"rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
<javascript:>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+***@googlegroups.com.
To post to this group, send an email to rabbitmq-***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Alvaro Videla
2015-03-09 15:53:52 UTC
Permalink
Are you sharing the channel across many instances of your consumer?
Post by r***@meltwater.com
package com.company.masf.search.consumer;
import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Envelope;
import com.rabbitmq.client.QueueingConsumer;
import com.rabbitmq.client.ShutdownSignalException;
import com.rabbitmq.client.impl.LongStringHelper;
public class DeleteSearchConsumer extends QueueingConsumer {
Log LOG = LogFactory.getLog(DeleteSearchConsumer.class);
public DeleteSearchConsumer(Channel channel) {
super(channel);
}
@Override
public void handleDelivery(java.lang.String consumerTag,
Envelope envelope,
AMQP.BasicProperties properties,
byte[] body) throws IOException {
LOG.info("We got a message: "+ body.toString());
SavedSearch search = null;
Channel channel = getChannel();
Long savedSearchId = getSavedSearchLong(body);
LOG.info("properties" + properties);
LOG.info("body" + body);
channel.basicAck(envelope.getDeliveryTag(), false);
}
@Override
public void handleShutdownSignal(java.lang.String consumerTag,
ShutdownSignalException sig) {
LOG.info("Channel closed", sig);
}
private Long getSavedSearchLong(byte[] searchId) {
String searchIdLongString = LongStringHelper.asLongString(
searchId).toString();
Long searchIdLong = Long.parseLong(searchIdLongString);
return searchIdLong;
}
}
2015-03-09 10:30:35 DeleteSearchConsumer [INFO ] [pool-2-thread-9]: body[
com.rabbitmq.client.AlreadyClosedException: channel is already closed due
to channel error; protocol method: #method<channel.close>(reply-code=406,
reply-text=PRECONDITION_FAILED - unknown delivery tag 1, class-id=60,
method-id=80)
at com.rabbitmq.client.impl.AMQChannel.ensureIsOpen(AMQChannel.
java:190)
291)
285)
at com.rabbitmq.client.impl.ChannelN.basicAck(ChannelN.java:1012)
at com.bla.masf.search.consumer.DeleteSearchConsumer.
handleDelivery(DeleteSearchConsumer.java:37)
at com.rabbitmq.client.impl.ConsumerDispatcher$5.run(
ConsumerDispatcher.java:144)
at com.rabbitmq.client.impl.ConsumerWorkService$WorkPoolRunnable.
run(ConsumerWorkService.java:95)
at java.util.concurrent.ThreadPoolExecutor.runWorker(
ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(
ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Post by Alvaro Videla
Is better to post some sample code and perhaps error logs from the
server. The error received at the client side would also be helpful.
Nonetheless, usually when a channel is closed due to a basicAck it might
mean that your app is sending the wrong delivery_tag back to the server.
Are you perhaps sharing channels across threads?
I have a basic consumer, on the handleDelivery i send basicAck and on the
Post by Alvaro Videla
Post by r***@meltwater.com
next messaged an get an error saying that that channel is closed, how can i
fix this? probably i'm using the Consumers the wrong way.
thanks.
--
You received this message because you are subscribed to the Google
Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
Post by r***@meltwater.com
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+***@googlegroups.com.
To post to this group, send an email to rabbitmq-***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Simon MacMullen
2015-03-09 15:59:52 UTC
Permalink
com.rabbitmq.client.AlreadyClosedException:channel isalready closed due
to channel error;protocol method:#method<channel.close>(reply-code=406,
reply-text=PRECONDITION_FAILED - unknown delivery tag 1
So either you have some threading related confusion as Alvaro suggested,
or you are acking messages delivered in no-ack mode.

Either way, you acked message #1 when the server thought it was not
unacknowledged.

Cheers, Simon
--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+***@googlegroups.com.
To post to this group, send an email to rabbitmq-***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Michael Klishin
2015-03-09 19:11:06 UTC
Permalink
Post by Simon MacMullen
So either you have some threading related confusion as Alvaro
suggested,
or you are acking messages delivered in no-ack mode.
Either way, you acked message #1 when the server thought it was not
unacknowledged.
or the  ack was sent not on the channel the delivery was on.
--
MK

Staff Software Engineer, Pivotal/RabbitMQ
--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+***@googlegroups.com.
To post to this group, send an email to rabbitmq-***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...