Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
package com.springbootdev.samples.rabbitmq.consumer.listener;
import com.springbootdev.samples.rabbitmq.consumer.model.Order;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
public class Consumer
private static final Logger LOGGER = LoggerFactory.getLogger(Consumer.class);
private static final String QUEUE_NAME = "orders_queue";
private RabbitTemplate rabbitTemplate;
public void pullMessage()
{"receiving the message ");
Object message = rabbitTemplate.receiveAndConvert(QUEUE_NAME);
if (message != null) {
Order order = (Order) message;" received message [" + order.toString() + "] ");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment