[rabbitmq-discuss] Spring AMQP: would like to put message to queue and send ACK immediately

bunny sunnybunny14 at gmail.com
Tue Aug 14 13:13:42 BST 2012

 0 down vote favorite<http://stackoverflow.com/questions/11951508/spring-amqp-would-like-to-put-message-to-queue-and-send-ack-immediately#> 
I wrote Java application, that sends messages to RabbitMQ. Then Flume picks 
messages up from RabbitMQ queue. I'm interested that nobody pulls messages 
from the queue, except flume.

My application uses Spring AMQP Java plugin.
The problem: 

With the code below, message comes to RabbitMQ queue and stays 
'Unknowledges' for ever. As I understand, RabbitMQ is waiting for ACK from 
MessageListener, but MessageListener will never ACK. Does anybody have idea 
how to fix it?

The code:

public class MyAmqpConfiguration {

    ConnectionFactory connectionFactory;

    public SimpleMessageListenerContainer messageListenerContainer() {

    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(connectionFactory);

    return container;

        public RabbitTemplate rabbitTemplate() {
        RabbitTemplate template = new RabbitTemplate(connectionFactory);
        return template;

public class MyMessageListener implements MessageListener {

   public MyMessageListener(MessageConverter converter, MyMessageHandler<MyObject> messageHandler) {
      this.converter = converter;
      this.messageHandler = messageHandler;

   public void onMessage(Message message) {


public class MyMessageHandler  {

     RabbitTemplate template;

     public void handleMessage(MyObject thing) {
         template.convertAndSend(exchange, routingKey, thing);


public class MyMessageConverter extends JsonMessageConverter {

     protected Message createMessage(Object object, MessageProperties messageProperties) { 
        //do things

     public Object fromMessage(Message message) throws MessageConversionException {
         throw new UnsupportedOperationException("fromMessage is not supported in "+this.getClass().getName());


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

More information about the rabbitmq-discuss mailing list