KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > Jt > examples > jms > JMSReceiver


1 package Jt.examples.jms;
2
3 import Jt.*;
4 import Jt.jms.*;
5 import java.io.*;
6
7
8 // Demonstrates the use of JtJMSQueueAdapter (synchronous mode).
9
// Use the adapter itself (Jt.jms.JtJMSQueueAdapter) to send messages to the
10
// JMS queue.
11

12 public class JMSReceiver {
13
14
15   // Test program (JMSQueue adapter)
16

17   public static void main(String JavaDoc[] args) {
18
19     JtFactory main = new JtFactory (); // Jt Factory
20
JtMessage msg;
21     String JavaDoc greeting;
22     String JavaDoc reply;
23     Jt.jms.JtJMSQueueAdapter jmsAdapter;
24
25
26     // Create the JMS adapter (point-to-point)
27

28     jmsAdapter = (Jt.jms.JtJMSQueueAdapter) main.createObject
29         ("Jt.jms.JtJMSQueueAdapter", "jmsAdapter");
30
31        
32     // Receive all the messages (Jt messages)
33

34     for (;;) {
35
36       msg = (JtMessage) main.sendMessage (jmsAdapter, new JtMessage ("JtRECEIVE"));
37
38       if (msg == null) {
39         System.out.println ("no more messages");
40         break;
41       }
42
43       System.out.println ("msgId:" + msg.getMsgId ());
44
45     }
46  
47
48     // Remove jmsAdapter
49

50     main.removeObject ("jmsAdapter");
51
52         
53
54   }
55
56 }
57
58
59
60
Popular Tags