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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.