publish Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory"); env.put(Context.PROVIDER_URL, "ormi://localhost:23791"); env.put(Context.SECURITY_CREDENTIALS, "oc4jadmin"); env.put(Context.SECURITY_PRINCIPAL, "oc4jadmin"); try { InitialContext ctx = new InitialContext(env); QueueConnectionFactory tconFactory_ = (QueueConnectionFactory) ctx.lookup("java:comp/resource/testQ/QueueConnectionFactories/qcf"); QueueConnection tcon_ = tconFactory_.createQueueConnection(); QueueSession tsession_ = tcon_.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue_ = (javax.jms.Queue) ctx.lookup("java:comp/resource/testQ/Queues/aqDemoQueue"); QueueSender tSender_ = tsession_.createSender(queue_); for (int i = 0; i < number; i++) { TextMessage msg = tsession_.createTextMessage(); msg.setText(content); tSender_.send(msg); } tSender_.close(); tsession_.close(); tcon_.close(); System.out.println("######send " + number + " event#######"); } catch (Exception e) { e.printStackTrace(); } subscribe Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory"); env.put(Context.PROVIDER_URL, "ormi://10.101.3.206:23791"); env.put(Context.SECURITY_CREDENTIALS, "oc4jadmin"); env.put(Context.SECURITY_PRINCIPAL, "oc4jadmin"); Message msg = null; try { InitialContext ctx = new InitialContext(env); QueueConnectionFactory tconFactory_ = (QueueConnectionFactory) ctx.lookup("java:comp/resource/testQ/QueueConnectionFactories/qcf"); QueueConnection tcon_ = tconFactory_.createQueueConnection(); QueueSession tsession_ = tcon_.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue_ = (javax.jms.Queue) ctx.lookup("java:comp/resource/testQ/Queues/aqDemoQueue"); MessageConsumer consumer = tsession_.createReceiver(queue_); tcon_.start(); msg = consumer.receive(3000); while (msg != null) msg = consumer.receive(3000); System.out.println(msg); consumer.close(); tsession_.close(); tcon_.close(); } catch (Exception e) { e.printStackTrace(); } return msg;