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 VidelaIs 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.comI 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.