AS 7 Messaging ( HORNETQ ) Client access remote:// Problem with Server listening on 0.0.0.0 Interface
rodakr Jun 15, 2012 2:08 AMHi
I see interessting Problem, when AS7 Server is configured on IP 0.0.0.0 ( means all IP's on this server AS7 runs on).
Simple Stand Alone Client Accessing JMS Connection Factory over Jboss Naming Remote :
final Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
env.put(Context.PROVIDER_URL, "remote://linuxServer:4447");
env.put(Context.SECURITY_PRINCIPAL, "admin");
env.put(Context.SECURITY_CREDENTIALS, "administrator");
InitialContext context = new InitialContext(env);
return context;
String connectionFactoryString = System.getProperty("connection.factory", "jms/RemoteConnectionFactory");
connectionFactory = (ConnectionFactory) context.lookup(connectionFactoryString);
destination = (Destination) context.lookup("jms/queue/test");
connection = connectionFactory.createConnection(System.getProperty("username", admin), System.getProperty("password",administrator));
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
My remote:// standalone Client can connect to AS7 server, pass authentication, can lookup JMS Connection Factory and when try to create JMS Session gets this Exception:
log4j:WARN No appenders could be found for logger (org.jboss.logging).
log4j:WARN Please initialize the log4j system properly.
15.06.2012 07:53:16 com.test.client.QuickJmsTest testRemoteJMS
INFO: Attempting to acquire connection factory "jms/RemoteConnectionFactory"
15.06.2012 07:53:16 com.test.client.QuickJmsTest testRemoteJMS
INFO: Found connection factory "jms/RemoteConnectionFactory" in JNDI
15.06.2012 07:53:16 com.test.client.QuickJmsTest testRemoteJMS
INFO: Attempting to acquire destination "jms/queue/test"
15.06.2012 07:53:16 com.test.client.QuickJmsTest testRemoteJMS
INFO: Found destination "jms/queue/test" in JNDI
15.06.2012 07:53:16 org.hornetq.core.logging.impl.JULLogDelegate trace
AM FEINSTEN: getConnectionWithRetry::1 with retryInterval = 2000 multiplier = 1.0
java.lang.Exception: trace
at org.hornetq.core.client.impl.ClientSessionFactoryImpl.getConnectionWithRetry(ClientSessionFactoryImpl.java:974)
at org.hornetq.core.client.impl.ClientSessionFactoryImpl.connect(ClientSessionFactoryImpl.java:225)
at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:752)
at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:601)
at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:119)
at com.test.client.QuickJmsTest.testRemoteJMS(QuickJmsTest.java:140)
at com.test.client.QuickJmsTest.main(QuickJmsTest.java:75)
15.06.2012 07:53:16 org.hornetq.core.logging.impl.JULLogDelegate debug
FEIN: Trying reconnection attempt 0/1
15.06.2012 07:53:16 org.hornetq.core.logging.impl.JULLogDelegate debug
FEIN: Trying to connect with connector = org.hornetq.core.remoting.impl.netty.NettyConnectorFactory@a4488, parameters = {port=5445, host=0.0.0.0} connector = NettyConnector [host=0.0.0.0, port=5445, httpEnabled=false, useServlet=false, servletPath=/messaging/HornetQServlet, sslEnabled=false, useNio=false]
15.06.2012 07:53:16 org.hornetq.core.logging.impl.JULLogDelegate debug
FEIN: Started Netty Connector version 3.2.5.Final-a96d88c
15.06.2012 07:53:16 org.hornetq.core.logging.impl.JULLogDelegate debug
FEIN: Trying to connect at the main server using connector :org-hornetq-core-remoting-impl-netty-NettyConnectorFactory?port=5445&host=0-0-0-0
15.06.2012 07:53:16 org.hornetq.core.logging.impl.JULLogDelegate debug
FEIN: Remote destination: /0.0.0.0:5445
15.06.2012 07:53:17 org.hornetq.core.logging.impl.JULLogDelegate debug
FEIN: Main server is not up. Hopefully there's a backup configured now!
15.06.2012 07:53:17 org.hornetq.core.logging.impl.JULLogDelegate trace
AM FEINSTEN: No Backup configured!
java.lang.Exception: trace
at org.hornetq.core.client.impl.ClientSessionFactoryImpl.getConnection(ClientSessionFactoryImpl.java:1224)
at org.hornetq.core.client.impl.ClientSessionFactoryImpl.getConnectionWithRetry(ClientSessionFactoryImpl.java:994)
at org.hornetq.core.client.impl.ClientSessionFactoryImpl.connect(ClientSessionFactoryImpl.java:225)
at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:752)
at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:601)
at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:119)
at com.test.client.QuickJmsTest.testRemoteJMS(QuickJmsTest.java:140)
at com.test.client.QuickJmsTest.main(QuickJmsTest.java:75)
15.06.2012 07:53:17 org.hornetq.core.logging.impl.JULLogDelegate trace
AM FEINSTEN: returning connection = null as tc == null
15.06.2012 07:53:17 org.hornetq.core.logging.impl.JULLogDelegate debug
FEIN: Trying to connect towards ClientSessionFactoryImpl [serverLocator=ServerLocatorImpl [initialConnectors=[org-hornetq-core-remoting-impl-netty-NettyConnectorFactory?port=5445&host=0-0-0-0], discoveryGroupConfiguration=null], connectorConfig=org-hornetq-core-remoting-impl-netty-NettyConnectorFactory?port=5445&host=0-0-0-0, backupConfig=null]
15.06.2012 07:53:17 com.test.client.QuickJmsTest testRemoteJMS
SCHWERWIEGEND: Failed to create session factory
Exception in thread "main" javax.jms.JMSException: Failed to create session factory
at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:605)
at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:119)
at com.test.client.QuickJmsTest.testRemoteJMS(QuickJmsTest.java:140)
at com.test.client.QuickJmsTest.main(QuickJmsTest.java:75)
Caused by: HornetQException[errorCode=2 message=Cannot connect to server(s). Tried with all available servers.]
at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:774)
at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:601)
... 3 more
The Problem is that org.hornetq.core.client.impl.ClientSessionFactoryImpl.getConnectionWithRetry use informations aquired from remote side from org.hornetq.core.remoting.impl.netty.NettyConnectorFactory to connect to hornetq JMS Server in AS7... and not the information client passt to initial context for lookup...
I see here some possible coding solutions:
- Server Side resolve 0.0.0.0 to IP Addresses and set this ins o rg.hornetq.core.remoting.impl.netty.NettyConnectorFactory
- Client side api, if address 0.0.0.0, use ip from JNDI lookup....
Or ist there allready another solution?