Methods Summary |
---|
private static void | executeQueue()
QueueConnection cnn = null;
QueueSender sender = null;
QueueSession session = null;
Queue queue = (Queue) getInitialContext().lookup("queue/mdbtest");
QueueConnectionFactory factory = (QueueConnectionFactory) getInitialContext().lookup("java:/ConnectionFactory");
cnn = factory.createQueueConnection();
session = cnn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
TextMessage msg = session.createTextMessage("Hello World");
sender = session.createSender(queue);
sender.send(msg);
Thread.sleep(1000);
session.close();
cnn.close();
|
private static void | executeTopic()
TopicConnection cnn = null;
TopicPublisher sender = null;
TopicSession session = null;
Topic topic = (Topic) getInitialContext().lookup("topic/topictest");
TopicConnectionFactory factory = (TopicConnectionFactory) getInitialContext().lookup("java:/ConnectionFactory");
cnn = factory.createTopicConnection();
session = cnn.createTopicSession(false, QueueSession.AUTO_ACKNOWLEDGE);
TextMessage msg = session.createTextMessage("Hello World");
sender = session.createPublisher(topic);
sender.send(msg);
Thread.sleep(1000);
session.close();
cnn.close();
|
public static javax.naming.InitialContext | getInitialContext()
Hashtable props = getInitialContextProperties();
return new InitialContext(props);
|
private static java.util.Hashtable | getInitialContextProperties()
Hashtable props = new Hashtable();
props.put("java.naming.factory.initial", "org.jnp.interfaces.LocalOnlyContextFactory");
props.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
return props;
|
public static void | main(java.lang.String[] args)
EJB3StandaloneBootstrap.boot(null);
// initialize JBoss MQ core services
EJB3StandaloneBootstrap.deployXmlResource("jboss-jms-beans.xml");
// initialize configured test queue and topic
EJB3StandaloneBootstrap.deployXmlResource("testjms.xml");
// scan classpath for ejbs and MDBs
EJB3StandaloneBootstrap.scanClasspath();
executeQueue();
executeTopic();
EJB3StandaloneBootstrap.shutdown();
|