1 7 package org.jboss.tutorial.mdb.client; 8 9 import javax.jms.Queue ; 10 import javax.jms.QueueConnection ; 11 import javax.jms.QueueConnectionFactory ; 12 import javax.jms.QueueSender ; 13 import javax.jms.QueueSession ; 14 import javax.jms.TextMessage ; 15 import javax.naming.InitialContext ; 16 17 public class Client 18 { 19 public static void main(String [] args) throws Exception 20 { 21 QueueConnection cnn = null; 22 QueueSender sender = null; 23 QueueSession session = null; 24 InitialContext ctx = new InitialContext (); 25 Queue queue = (Queue ) ctx.lookup("queue/tutorial/example"); 26 QueueConnectionFactory factory = (QueueConnectionFactory ) ctx.lookup("ConnectionFactory"); 27 cnn = factory.createQueueConnection(); 28 session = cnn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE); 29 30 TextMessage msg = session.createTextMessage("Hello World"); 31 32 sender = session.createSender(queue); 33 sender.send(msg); 34 System.out.println("Message sent successfully to remote queue."); 35 36 } 37 } 38 | Popular Tags |