KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > tutorial > mdb_deployment_descriptor > client > Client


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.tutorial.mdb_deployment_descriptor.client;
8
9 import javax.jms.Queue JavaDoc;
10 import javax.jms.QueueConnection JavaDoc;
11 import javax.jms.QueueConnectionFactory JavaDoc;
12 import javax.jms.QueueSender JavaDoc;
13 import javax.jms.QueueSession JavaDoc;
14 import javax.jms.TextMessage JavaDoc;
15 import javax.naming.InitialContext JavaDoc;
16
17 public class Client
18 {
19    public static void main(String JavaDoc[] args) throws Exception JavaDoc
20    {
21       QueueConnection JavaDoc cnn = null;
22       QueueSender JavaDoc sender = null;
23       QueueSession JavaDoc session = null;
24       InitialContext JavaDoc ctx = new InitialContext JavaDoc();
25       Queue JavaDoc queue = (Queue JavaDoc) ctx.lookup("queue/tutorial/example");
26       QueueConnectionFactory JavaDoc factory = (QueueConnectionFactory JavaDoc) ctx.lookup("ConnectionFactory");
27       cnn = factory.createQueueConnection();
28       session = cnn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
29
30       TextMessage JavaDoc 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