Remote JMS connection over NAT'ed IP
swatkat1976 Jul 17, 2007 12:00 PMHi,
I am trying to connect to a remote JMS queue from my JBoss Server 4.0.3SP1 and using JBossMQ. The other server also hosts JBossMQ.
The machines involved and their IPs are as below:
The client Machine:
Name: XYZ
Config: JBoss Server 4.0.3SP1
Network IP: 122.xx.xx.xx {Say Network MC)
The host machine:
Name: ABC
JBoss Server 4.0.2
Network IP: 60.23.xx.xx {Say Network JS}
JMS Config: JBossMQ and is configured with HAJNDI on port 1100
Connection from Machine ABC to XYZ:
Method: VPN
Host IP: 122.xx.xx.xx {Network MC}
NAT'ed IP: 172.xx.xx.xxx {NATIP}, this IP has port mapping to
Final Destination IP 60.23.xx.xx {Network JS}
Ports Mapped: 1100 and 1099,
I can ping,telnet and access Network JS from Network MC through NATIP
Remote host hajndi-jms-ds.xml file
<mbean code="org.jboss.jms.jndi.JMSProviderLoader" name="jboss.mq:service=JMSProviderLoader,name=HAJNDIJMSProvider"> <attribute name="ProviderName">DefaultJMSProvider</attribute> <attribute name="ProviderAdapterClass"> org.jboss.jms.jndi.JNDIProviderAdapter </attribute> <!-- The combined connection factory --> <attribute name="FactoryRef">java:/XAConnectionFactory</attribute> <!-- The queue connection factory --> <attribute name="QueueFactoryRef">XAConnectionFactory</attribute> <!-- The topic factory --> <attribute name="TopicFactoryRef">XAConnectionFactory</attribute> <!-- Access JMS via HAJNDI --> <attribute name="Properties"> java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces java.naming.provider.url=<someObscureServer>.com:1100 </attribute> </mbean>
Remote JNDIView Output: using NAT'ed IP http://172.xx.xx.xxx:8080/jmx-console/HtmlAdaptor
java: Namespace +- JmsXA +- ConnectionFactory +- DefaultJMSProvider +- XAConnectionFactory Global JNDI Namespace +- ConnectionFactory +- HTTPConnectionFactory +- XAConnectionFactory +- UILXAConnectionFactory[link -> XAConnectionFactory] +- UIL2XAConnectionFactory[link -> XAConnectionFactory] +- UIL2ConnectionFactory[link -> ConnectionFactory] +- UILConnectionFactory[link -> ConnectionFactory] +- queue | +- A | +- DataFeed
I have made various attempts to connect to remote JNDI using the configurations below
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Trial 1 JMS Provider on port 1100
jms-ds.xml
<mbean code="org.jboss.jms.jndi.JMSProviderLoader" name="jboss.mq:service=JMSProviderLoader,name=RemoteJMSProvider,server=RemoteSite"> <attribute name="ProviderName">RemoteSiteJMSProvider</attribute> <attribute name="ProviderAdapterClass">org.jboss.jms.jndi.JNDIProviderAdapter</attribute> <attribute name="QueueFactoryRef">XAConnectionFactory</attribute> <attribute name="TopicFactoryRef">XAConnectionFactory</attribute> <attribute name="Properties"> java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces java.naming.provider.url=172.xx.xx.xxx:1100 </attribute> </mbean> <tx-connection-factory> <jndi-name>JSTJmsXA</jndi-name> <rar-name>jms-ra.rar</rar-name> <connection-definition>org.jboss.resource.adapter.jms.JmsConnectionFactory</connection-definition> <config-property name="SessionDefaultType" type="java.lang.String">javax.jms.Queue</config-property> <config-property name="JmsProviderAdapterJNDI" type="java.lang.String">java:/RemoteSiteJMSProvider</config-property> </tx-connection-factory>
Java Code: (Standalone Java Client)
properties.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory"); properties.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces"); properties.put("java.naming.provider.url","jnp://localhost:1099"); initialContext = new InitialContext(properties); queueConFac = (QueueConnectionFactory) initialContext.lookup("JSTJmsXA");
Result:
javax.naming.NameNotFoundException: JSTJmsXA not bound
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Trial 2 External Context on port 1100
jms-ds.xml
<mbean code="org.jboss.naming.ExternalContext" name="jboss.jndi:service=ExternalContext,jndiName=jstRemoteJNDI"> <attribute name="JndiName">jstRemoteJNDI</attribute> <attribute name="Properties"> java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory java.naming.factory.url.pkgs=org.jnp.interfaces java.naming.provider.url=172.xx.xx.xxx:1100 </attribute> <attribute name="InitialContext">javax.naming.InitialContext</attribute> <attribute name="RemoteAccess">true</attribute> <depends>jboss:service=Naming</depends> </mbean>
JNDIView Output:
Global JNDI Namespace
+- jstRemoteJNDI error while listing context javax.naming.InitialContext@1054f93: javax.naming.CommunicationException [Root exception is java.rmi.RemoteException: Service unavailable.]javax.naming.CommunicationException [Root exception is java.rmi.RemoteException: Service unavailable.] at org.jnp.interfaces.NamingContext.list(NamingContext.java:797)
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Trial 3 External Context on port 1099
jms-ds.xml
<mbean code="org.jboss.naming.ExternalContext" name="jboss.jndi:service=ExternalContext,jndiName=jstRemoteJNDI"> <attribute name="JndiName">jstRemoteJNDI</attribute> <attribute name="Properties"> java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory java.naming.factory.url.pkgs=org.jnp.interfaces java.naming.provider.url=172.xx.xx.xxx:1099 </attribute> <attribute name="InitialContext">javax.naming.InitialContext</attribute> <attribute name="RemoteAccess">true</attribute> <depends>jboss:service=Naming</depends> </mbean>
JNDIView Output: {Connection refused to actual Remote IP instead of NAT'ed IP
+- jstRemoteJNDI error while listing context javax.naming.InitialContext@a4be02: javax.naming.CommunicationException [Root exception is java.rmi.ConnectException: Connection refused to host: 60.23.xx.xx; nested exception is: java.net.ConnectException: Connection refused: connect
I have referred to the postings below but have not been able to figure out the problem yet.
http://wiki.jboss.org/wiki/Wiki.jsp?page=HowDoIConfigureTheJMSResourceAdapterToUseARemoteConnectionFactory
http://wiki.jboss.org/wiki/Wiki.jsp?page=HowDoIConfigureAnMDBToTalkToARemoteQueue
http://www.jboss.org/wiki/Wiki.jsp?page=JBossNS
http://www.jboss.org/wiki/Wiki.jsp?page=JBossNSFAQ