Search code examples
springspring-bootspring-integrationspring-rabbit

Spring boot- RabbitMQ consumer keep on printing "Retrieving delivery for Consumer"


Hi I am using Spring boot 1.3.5 along with starter RabbitMQ. In this project i am having a RabbitMQ consumer which consumes messages from a particular queue.But while running the application it keeps on printing below message in the console.while browsing in google i read setting heartBeat will resolve the issue but no luck for me,

14:08:14.892 [SimpleAsyncTaskExecutor-1] DEBUG o.s.a.r.l.BlockingQueueConsumer - Retrieving delivery for Consumer: tags=[{amq.ctag-rDkzcToXLMWqF4fFUIHS0A=notificationQueue}], channel=Cached Rabbit Channel: AMQChannel(amqp://guest@127.0.0.1:5672/,3), conn: Proxy@47914ea3 Shared Rabbit Connection: SimpleConnection@1096fe75 [delegate=amqp://guest@127.0.0.1:5672/], acknowledgeMode=AUTO local queue size=0
14:08:14.913 [SimpleAsyncTaskExecutor-3] DEBUG o.s.a.r.l.BlockingQueueConsumer - Retrieving delivery for Consumer: tags=[{amq.ctag-jxyjMKfw6heu77XVdYh3tw=notificationQueue}], channel=Cached Rabbit Channel: AMQChannel(amqp://guest@127.0.0.1:5672/,2), conn: Proxy@47914ea3 Shared Rabbit Connection: SimpleConnection@1096fe75 [delegate=amqp://guest@127.0.0.1:5672/], acknowledgeMode=AUTO local queue size=0
14:08:14.917 [SimpleAsyncTaskExecutor-2] DEBUG o.s.a.r.l.BlockingQueueConsumer - Retrieving delivery for Consumer: tags=[{amq.ctag-AcbX0R5eM-ukqWN0a_nrwA=notificationQueue}], channel=Cached Rabbit Channel: AMQChannel(amqp://guest@127.0.0.1:5672/,1), conn: Proxy@47914ea3 Shared Rabbit Connection: SimpleConnection@1096fe75 [delegate=amqp://guest@127.0.0.1:5672/], acknowledgeMode=AUTO local queue size=0
14:08:15.893 [SimpleAsyncTaskExecutor-1] DEBUG o.s.a.r.l.BlockingQueueConsumer - Retrieving delivery for Consumer: tags=[{amq.ctag-rDkzcToXLMWqF4fFUIHS0A=notificationQueue}], channel=Cached Rabbit Channel: AMQChannel(amqp://guest@127.0.0.1:5672/,3), conn: Proxy@47914ea3 Shared Rabbit Connection: SimpleConnection@1096fe75 [delegate=amqp://guest@127.0.0.1:5672/], acknowledgeMode=AUTO local queue size=0

It's ever ending.Kindly find the below consumer code:

RabbitMqConfiguration.java

import org.springframework.amqp.rabbit.annotation.EnableRabbit;
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableRabbit
public class RabbitMqConfiguration{

@Autowired
private CachingConnectionFactory cachingConnectionFactory;

@Value("${concurrent.consumers}")
public int concurrent_consumers;

@Value("${max.concurrent.consumers}")
public int max_concurrent_consumers;

@Bean
public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory() {
        SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
        factory.setConnectionFactory(cachingConnectionFactory);
        factory.setConcurrentConsumers(concurrent_consumers);
        factory.setMaxConcurrentConsumers(max_concurrent_consumers);
        factory.setMessageConverter(jsonMessageConverter());
        return factory;
    }

@Bean
public MessageConverter jsonMessageConverter()
{
    final Jackson2JsonMessageConverter converter = new Jackson2JsonMessageConverter();
    return converter;
}

}

NotificationConsumer.java

@Component
public class NotificationConsumer {

private static final Logger logger = LoggerFactory.getLogger(NotificationConsumer.class);

@Value("${notification.queue}")
public String notificationQueue;

@RabbitListener(id="notification",containerFactory="rabbitListenerContainerFactory",queues = "#{notificationQueue}")
public void handleNotificationMessage(Transaction transaction)
{
    System.out.println("Entered handleNotificationMessage::"+transaction.getId());
    System.out.println("Exit handleNotificationMessage::"+transaction.getData());

    logger.info("Entered handleNotificationMessage::", transaction.getId());
    logger.info("Exit handleNotificationMessage::", transaction.getData());
}

@Bean
public Queue notificationQueue() {
    return new Queue(notificationQueue, true, false, false);
}

}

application.yml

spring:
    rabbitmq:
        addresses: 127.0.0.1:5672
        adminAddresses: http://127.0.0.1:15672
        username: guest
        password: guest
        requested-heartbeat: 60

spring.rabbit.exchange: notification-exchange
notification.queue: notificationQueue
concurrent.consumers: 3
max.concurrent.consumers: 10

Message will be produced by another application and this application will only consume the message.

Your help should be appreciated.

As per Gary flipped the logger level from DEBUG to INFO resolved my issue.

logging:
    level:
        ROOT: INFO

Now i am getting following exception:

15:21:24.925 [SimpleAsyncTaskExecutor-2] WARN o.s.a.r.l.ConditionalRejectingErrorHandler - Fatal message conversion error; message rejected; it will be dropped or routed to a dead letter exchange, if so configured: (Body:'{"id":"5784eed4f5a64b4d8663e706","clientIdentifier":"313131313131", "data":"Sample data by vad","currentAction":{"state":{"status":"PENDING","errorCode":"404"},"data":"Sample data"}, "hasError":false,"errorMessage":""}'MessageProperties [headers={__TypeId__=com.global.produce.model.Transaction}, timestamp=null, messageId=null, userId=null, appId=null, clusterId=null, type=null, correlationId=null, replyTo=null, contentType=application/json, contentEncoding=UTF-8, contentLength=0, deliveryMode=PERSISTENT, expiration=null, priority=0, redelivered=false, receivedExchange=, receivedRoutingKey=notificationQueue, deliveryTag=1, messageCount=0])

Anyone have any idea about this error?


Solution

  • That's just a DEBUG log; change the log settings to INFO or WARN or ERROR.