KickJava   Java API By Example, From Geeks To Geeks.

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


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 (asynchronous mode).
9

10 public class JMSAsyncReceiver {
11
12
13
14
15   // Test program
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     JtEcho echo = new JtEcho ();
25     JtKeyboard keyboard = new JtKeyboard ();
26
27
28     // Create the JMS adapter (point-to-point)
29

30     jmsAdapter = (Jt.jms.JtJMSQueueAdapter) main.createObject
31         ("Jt.jms.JtJMSQueueAdapter", "jmsAdapter");
32
33     // Asynchronous mode. Incoming messages will be redirected to echo
34

35     main.setValue (jmsAdapter, "subject", echo);
36     main.sendMessage (jmsAdapter, new JtMessage ("JtSTART_LISTENING"));
37
38
39     System.out.println ("Listening for asynchronous messages ... ");
40  
41     main.sendMessage (keyboard, new JtMessage ("JtACTIVATE"));
42         
43
44     // Remove jmsAdapter
45

46     main.removeObject ("jmsAdapter");
47
48         
49
50   }
51
52 }
53
54
55
56
Popular Tags