1 22 package org.jboss.ejb3.test.jca.inflowmdb; 23 24 import javax.ejb.Stateless ; 25 import javax.ejb.Remote ; 26 import javax.jms.Queue ; 27 import javax.jms.QueueConnection ; 28 import javax.jms.QueueConnectionFactory ; 29 import javax.jms.QueueSender ; 30 import javax.jms.QueueSession ; 31 import javax.jms.TextMessage ; 32 import javax.naming.InitialContext ; 33 34 import org.jboss.ejb3.InitialContextFactory; 35 36 import org.jboss.logging.Logger; 37 38 42 @Stateless 43 @Remote (StatelessRemote.class) 44 public class StatelessBean implements StatelessRemote 45 { 46 private static final Logger log = Logger.getLogger(StatelessBean.class); 47 48 public void sendMessage() throws Exception 49 { 50 QueueConnection cnn = null; 51 QueueSender sender = null; 52 QueueSession session = null; 53 54 InitialContext jndiContext = InitialContextFactory.getInitialContext(); 55 56 Queue queue = (Queue ) jndiContext.lookup("queue/inflowmdbtest"); 57 QueueConnectionFactory factory = (QueueConnectionFactory ) jndiContext.lookup("java:/ConnectionFactory"); 58 cnn = factory.createQueueConnection(); 59 session = cnn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE); 60 61 TextMessage msg = session.createTextMessage("Hello World"); 62 63 sender = session.createSender(queue); 64 65 sender.send(msg); 66 } 67 } 68 | Popular Tags |