daily pastebin goal
71%
SHARE
TWEET

Untitled

a guest Jan 18th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. protected LinkedBlockingQueue<Message> messages = new LinkedBlockingQueue<>();
  2.  
  3.     public void receiveMessages() {
  4.         try {
  5. //            channel.basicQos(pollCount);
  6.             Message message = new Message();
  7.             Consumer consumer = new DefaultConsumer(channel) {
  8.                 @Override
  9.                 public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body)
  10.                         throws IOException {
  11.                     long deliveryTag = envelope.getDeliveryTag();
  12.                     String response = new String(body, "UTF-8");
  13.                     if (response != null) {
  14.                         message.setId(NUID.nextGlobal());
  15.                         message.setPayload(response);
  16.                         message.setDeliveryTag(deliveryTag);
  17.                         messages.add(message);
  18.                         logger.info("Message received: ", message.getPayload());
  19.                     }
  20.                 }
  21.             };
  22.             logger.debug("**********Channel status: " + channel.isOpen());
  23.             channel.basicConsume(queueName, false, consumer);
  24.         } catch (Exception e) {
  25.             logger.error("Exception while getting messages from Rabbit ", e);
  26.  
  27.         }
  28.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top