We will start with a Java application, QueueProducer.java
, acting as a JMS queue producer. Recall how we use a queue in point-to-point messaging. Point-to-point is used when you want a particular recipient, or consumer, to process a given message just once. An example would be a message to process an order—we would want only one recipient to process this order and that recipient should process the order only once. Another example is an instruction to open a specific bank account. QueueProducer.java
just sends a message Open bank account 1234
to the queue. The code is shown below:
package ejb30.client;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.jms.*;
public class QueueProducer {
public static void main(String[] args) {
ConnectionFactory cf = null;
Connection conn = null;
Queue queue = null;
try {
InitialContext ctx = new InitialContext();
cf = (ConnectionFactory)
ctx.lookup("BankServiceConnectionFactory...