6.5. Writing Fanout Applications in Java JMS
This section describes three programs that implement fanout messaging in Java JMS:
Producer.java publishes messages to the amq.fanouteexchange.
Consumer.java uses a message consumer to receive messages from the amq.fanout exchange.
Listener.java uses a message listener to receive messages from the queue named message_queue.
Unlike the C++ and Python examples, our Java JMS examples use JNDI to establish the server environment instead of using a separate configuration program. In this example, every message that the producer writes to the fanout exchange is sent to the queues used by each listener or consumer.