To send a message, you must specify the destination message queue. The message service notifies listeners that are registered for the queue and the message remains in the queue until it is received and acknowledged.
Figure 3-2 illustrates the message flow that occurs when a client or component sends a message.
This example notifies a client of a completed order; it creates a new message, constructs the message text, and sends the message to the client’s queue:
public void notifyOrder(Session mySession, Queue queue, int orderNo, String product) { String text = "Order " + orderNo + " for product " + product + " was completed at " + time; MessageProducer sender = mySession.createProducer(myQueue); javax.jms.TextMessage textMsg = qSession.createTextMessage(text); textMsg.setStringProperty(“ProductDescription”, product); textMsg.setIntProperty(“OrderNumber”, orderNo); sender.send(textMsg); }