RabbitMQ — publish and subscribe

Once the RabbitMQ service is installed and it's up and running as can be verified from the RMQ, the management console's next obvious step is to write a quick publisher and consumer application. Following is the code snippet of the producer that publishes a message under an exchange called MYExchange on a queue called MyQueue.

package com.book.rmq; ... public class RMQProducer { private static String myRecord; private static final String EXCHANGE_NAME = "MYExchange"; private final static String QUEUE_NAME = "MYQueue"; private final static String ROUTING_KEY = "MYQueue"; public static void main(String[] argv) throws Exception { ConnectionFactory factory = new ConnectionFactory(); Address[] addressArr = { new ...

Get Practical Real-time Data Processing and Analytics now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.