From: Nasser M. <Nas...@tv...> - 2001-07-25 16:01:53
|
Hello, I am using a simple JMS based publish - subscribe arrangement with no MDBs (or a Request-Reply arrangement using queue), but JBossMQ as a remote router (accessed via the Internet) fails. Topic Client Application publish a simple hello message to JBoss under the following context: Properties p = new Properties(); p.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory"); p.put(Context.PROVIDER_URL, "myCompany.com:1099"); p.put(Context.URL_PKG_PREFIXES, "org.jboss.naming"); Context ctx = new InitialContext(p); JBoss as a jms router receives the Topic message, but fails to redirect the message to a remote Listener client Application. I have tried the system from within a LAN network and everything is fine, but having the Listener client application remotely via the Internet raises an exception: [Default] The connection to client ID21 failed etc. I have tested the same arrangement with the SUN JMQ product and its fine. Am I missing something? Unlike SUN JMQ, do I need to have JBoss server running on the Listener application also!? Any advice or help is welcome. I am using JBoss 2.4beta-tomcat3.2.2 Windows NT workstation. Here is the program code and the exceptions listing from the JBoss: [Default] The connection to client ID28 failed. [Default] java.io.IOException: The filename, directory name, or volume label syntax is incorrect [Default] at java.io.Win32FileSystem.canonicalize(Native Method) [Default] [Default] at java.io.File.getCanonicalPath(Unknown Source) [Default] [Default] at org.apache.tomcat.util.FileUtil.safePath(FileUtil.java:184) [Default] [Default] at org.apache.tomcat.core.Context.getRealPath(Context.java:797) [Default] [Default] at org.apache.tomcat.request.StaticInterceptor.requestMap(StaticInterceptor.java:196) [Default] [Default] at org.apache.tomcat.core.ContextManager.processRequest(ContextManager.java:820) [Default] [Default] at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:771) [Default] [Default] at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743) [Default] [Default] at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213 ) [Default] [Default] at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416) [Default] [Default] at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501) [Default] [Default] at java.lang.Thread.run(Unknown Source) [Default] //------------------------------------------------------------------------------------------------------------------- package org; import java.io.File; import java.util.Hashtable; import javax.naming.*; import javax.jms.*; import java.util.Properties; public class Sub implements MessageListener { TopicConnectionFactory topicConnectionFactory; TopicConnection topicConnection; TopicSession topicSession; TopicSubscriber topicSubscriber; Topic topic; public Sub() { try { Properties p = new Properties(); p.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory"); p.put(Context.PROVIDER_URL, "myCompany.com:1099"); p.put(Context.URL_PKG_PREFIXES, "org.jboss.naming"); Context ctx = new InitialContext(p); topic = (Topic)ctx.lookup("topic/testTopic"); topicConnectionFactory = (TopicConnectionFactory)ctx.lookup("TopicConnectionFactory"); ctx.close(); } catch(NameNotFoundException e) { System.out.print("The application could not locate the JMS"); System.out.println(" administered objects "); System.out.println("in the file system service provider."); System.out.println("Please execute the runjmqconfig script first."); System.exit(1); } catch(Exception e) { System.out.println("Exception: " + e.getMessage()); e.printStackTrace(); } try { topicConnection = topicConnectionFactory.createTopicConnection(); } catch (JMSException e) { System.out.println("JMSException: " + e.getMessage()); e.printStackTrace(); } catch(Exception e) { System.out.println("Exception: " + e.getMessage()); e.printStackTrace(); } try { topicSession = topicConnection.createTopicSession(false, TopicSession.AUTO_ACKNOWLEDGE); } catch (JMSException e) { System.out.println("JMSException: " + e.getMessage()); e.printStackTrace(); } catch(Exception e) { System.out.println("Exception: " + e.getMessage()); e.printStackTrace(); } subscribeMsg(); } private void subscribeMsg() { try { topicSubscriber = topicSession.createSubscriber(topic); topicSubscriber.setMessageListener(this); topicConnection.start(); System.out.println("Subscriber: Ready to receive messages...\n"); } catch (JMSException e) { System.out.println("JMSException: " + e.getMessage()); e.printStackTrace(); } catch (Exception e) { System.out.println("Exception: " + e.getMessage()); e.printStackTrace(); } } public void onMessage(Message mesg) { try { if (mesg instanceof TextMessage) if (((TextMessage)mesg).getText().equals("Close")) { System.exit(0); return; } System.out.println("Received: " + ((TextMessage)mesg).getText()); } catch (JMSException e) { System.out.println("JMSException: " + e.getMessage()); e.printStackTrace(); } catch (Exception e) { System.out.println("Exception: " + e.getMessage()); e.printStackTrace(); } } public static void main(String[] args) { org.Sub sub = new org.Sub(); } } //------------------------------------------------------------------------------------------------------------------- package org; import java.io.File; import java.util.Hashtable; import java.net.ConnectException; import javax.naming.*; import javax.jms.*; import java.util.Properties; public class Pub { TopicConnectionFactory topicConnectionFactory; TopicConnection topicConnection; TopicSession topicSession; TopicPublisher topicPublisher; Topic topic; public Pub() { try { Properties p = new Properties(); p.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory"); p.put(Context.PROVIDER_URL, "myCompany.com:1099"); p.put(Context.URL_PKG_PREFIXES, "org.jboss.naming"); Context ctx = new InitialContext(p); topicConnectionFactory = (TopicConnectionFactory)ctx.lookup("TopicConnectionFactory"); topic = (Topic)ctx.lookup("topic/testTopic"); ctx.close(); } catch(NameNotFoundException e) { System.out.print("The application could not locate the JMS"); System.out.println(" administered objects "); System.out.println("in the file system service provider."); System.out.println("Please execute the runjmqconfig script first."); System.exit(1); } catch(Exception e) { System.out.println("Exception: " + e.getMessage()); e.printStackTrace(); } try { topicConnection = topicConnectionFactory.createTopicConnection(); } catch (JMSException e) { System.out.print("The router is not running on the specified host"); System.out.print("Please check your router status and try to run"); System.out.println(" the example again.\n"); System.exit(1); } catch(Exception e) { System.out.println("Exception: " + e.getMessage()); e.printStackTrace(); } try { topicConnection.start(); topicSession = topicConnection.createTopicSession(false, TopicSession.AUTO_ACKNOWLEDGE); } catch (JMSException e) { System.out.println("JMSException: " + e.getMessage()); e.printStackTrace(); } catch(Exception e) { System.out.println("Exception: " + e.getMessage()); e.printStackTrace(); } publishMsg(); } private void publishMsg() { try { topicPublisher = topicSession.createPublisher(topic); System.out.println("Publisher: Waiting for the Subscriber to start...\n"); Thread.sleep(3000); System.out.println("Publisher: Ready to publish messages...\n"); String str; TextMessage textMessage = topicSession.createTextMessage(); for (int i = 1; i < 11; i++) { str = "Message " + i; textMessage.setText(str); topicPublisher.setDeliveryMode(DeliveryMode.NON_PERSISTENT); topicPublisher.publish(textMessage); System.out.println("Publishing: " + str); Thread.sleep(500); } textMessage.setText("Close"); topicPublisher.setDeliveryMode(DeliveryMode.NON_PERSISTENT); topicPublisher.publish(textMessage); topicSession.commit(); topicPublisher.close(); } catch (JMSException e) { System.out.println("JMSException: " + e.getMessage()); e.printStackTrace(); } catch(Exception e) { System.out.println("Exception: " + e); e.printStackTrace(); } System.exit(0); } public static void main(String[] args) { org.Pub pub = new org.Pub(); } } Many thanks in advance. |