1 23 package bridge; 24 25 import javax.jms.*; 26 27 30 public class ForeignConsumer { 31 public static void main(String [] args) throws Exception { 32 javax.naming.Context jndiCtx = new javax.naming.InitialContext (); 33 Destination foreignDest = (Destination) jndiCtx.lookup("foreignQueue"); 34 ConnectionFactory foreignCF = (ConnectionFactory) jndiCtx.lookup("foreignCF"); 35 jndiCtx.close(); 36 37 Connection foreignCnx = foreignCF.createConnection(); 38 Session foreignSess = foreignCnx.createSession(false, Session.AUTO_ACKNOWLEDGE); 39 MessageConsumer foreignCons = foreignSess.createConsumer(foreignDest); 40 foreignCons.setMessageListener(new MsgListener("foreign")); 41 foreignCnx.start(); 42 43 System.in.read(); 44 foreignCnx.close(); 45 } 46 } 47 | Popular Tags |