3131import javax .naming .InitialContext ;
3232import java .io .File ;
3333import java .util .ArrayList ;
34+ import java .util .Hashtable ;
3435import java .util .List ;
3536import java .util .Properties ;
3637
@@ -102,22 +103,7 @@ public void onException(Message msg, Exception ex) {
102103
103104 @ Test
104105 public void shouldFireMessageAsynchronously () throws Exception {
105-
106- // String strLine = "";
107- // try {
108- // // Get the object of DataInputStream
109- // InputStreamReader isr = new InputStreamReader(System.in);
110- // BufferedReader br = new BufferedReader(isr);
111- // String line = "";
112- // while ((line = br.readLine()) != null && !line.equals("exit") )
113- // strLine += br.readLine() + "~";
114- //
115- // isr.close();
116- // } catch (IOException ioe) {
117- // ioe.printStackTrace();
118- // }
119-
120- Properties properties = new Properties ();
106+ // final Properties properties = new Properties();
121107// properties.put("com.sun.appserv.iiop.endpoints", "localhost:7676");
122108// properties.put("org.omg.CORBA.ORBInitialHost", "localhost");
123109// properties.put("org.omg.CORBA.ORBInitialPort", "3700");
@@ -126,30 +112,34 @@ public void shouldFireMessageAsynchronously() throws Exception {
126112// properties.put("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
127113// properties.put("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
128114
115+ final Hashtable properties = new Hashtable (2 );
129116 properties .put (Context .INITIAL_CONTEXT_FACTORY , "com.sun.enterprise.naming.SerialInitContextFactory" );
130- properties .put (Context .URL_PKG_PREFIXES , "com.sun.enterprise.naming" );
131- properties .put (Context .STATE_FACTORIES , "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl" );
132- // properties.put("org.omg.CORBA.ORBInitialHost", "localhost");
133- // properties.put("org.omg.CORBA.ORBInitialPort", "3700");
134- properties .put (Context .PROVIDER_URL , "mq://localhost:7676" ); // vm://localhost:
135- // properties.put(Context.PROVIDER_URL, "iiop://localhost:7676"); // vm://localhost:
117+ properties .put (Context .PROVIDER_URL , "mq://localhost:7676" );
118+ properties .put ("java.naming.factory.url.pkgs" , "com.sun.enterprise.naming" );
119+ properties .put ("java.naming.factory.state" , "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl" );
120+
121+ // properties.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.enterprise.naming.SerialInitContextFactory");
122+ // properties.put(Context.URL_PKG_PREFIXES, "com.sun.enterprise.naming");
123+ // properties.put(Context.STATE_FACTORIES, "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
124+ //// properties.put("org.omg.CORBA.ORBInitialHost", "localhost");
125+ //// properties.put("org.omg.CORBA.ORBInitialPort", "3700");
126+ // properties.put(Context.PROVIDER_URL, "mq://localhost:7676"); // vm://localhost:
127+ //// properties.put(Context.PROVIDER_URL, "iiop://localhost:7676"); // vm://localhost:
136128
137129 System .out .println ("=====================================================================" );
138130 System .out .println ("=====================================================================" );
139- InitialContext jndiContext = new InitialContext (properties );
131+ final InitialContext jndiContext = new InitialContext (properties );
140132 System .out .printf ("\t jndiContext=%s\n " , jndiContext );
141133 System .out .println ("=====================================================================" );
142134 System .out .println ("=====================================================================" );
143135
144- ConnectionFactory connectionFactory =
145- (ConnectionFactory )jndiContext .lookup ("jms/demoConnectionFactory" );
136+ final ConnectionFactory connectionFactory = (ConnectionFactory )jndiContext .lookup ("java:comp:jms/demoConnectionFactory" );
137+
138+ final Queue queue = (Queue )jndiContext .lookup ("jms/demoQueue" );
146139
147- Queue queue = ( Queue ) jndiContext . lookup ( "jms/demoQueue" );
140+ final JMSContext context = connectionFactory . createContext ( Session . AUTO_ACKNOWLEDGE );
148141
149- Connection connection = connectionFactory .createConnection ();
150- JMSContext context = connectionFactory .createContext (
151- Session .AUTO_ACKNOWLEDGE );
152- JMSProducer producer = context .createProducer ();
142+ final JMSProducer producer = context .createProducer ();
153143
154144 messages .clear ();
155145
@@ -159,7 +149,7 @@ public void shouldFireMessageAsynchronously() throws Exception {
159149 producer .send (queue , "world" );
160150 producer .send (queue , "asynchronously" );
161151
162- Thread .sleep (2000 );
152+ Thread .sleep (1000 );
163153
164154 System .out .println ("Done" );
165155 }
0 commit comments