-
1. Re: JNDI unable to connect with HornetQ behind a load balancer
clebert.suconic Jan 13, 2010 7:34 PM (in response to johnnysoccer)I'm not really sure what this load balancer is doing.
The client needs access to the machine anyway. If you're putting a proxy or firewal in front of it for some reason, you need to proxy it properly.
Anyway, you're not required to use JNDI in order to establish the clients with HornetQ. You can use direct instantiation of the Factories with HornetQ (Look at the documentation and examples for more information).
-
2. Re: JNDI unable to connect with HornetQ behind a load balancer
johansyd Jul 27, 2011 10:36 AM (in response to johnnysoccer)I have had the same Problem for a couple of days now. And finally gave up on making lookups with jndi. I went through all the logs I could find and couldn't find a single log entry showing that a connection was established. Still I localy got "Coonection refused" together with the ip-address of one of the backend-servers which proves that the connection is being forwarded by the load balancer.
A professor I spoke with said it could be due to the fact that the load balancer was trying to send a a ip6 address to the backend servers which where expecting a ip4 address or something in this direction.
You should be able to get around your problem by connecting directly to the connector. I just managed to this. My solution is this:
Configs:
hornetq-beans.xml
<bean name="JNDIServer" class="org.jnp.server.Main">
<property name="namingInfo">
<inject bean="Naming"/>
</property>
<property name="port">${jnp.port:8050}</property>
<property name="bindAddress">${jnp.host:10.6.0.55}</property>
<property name="rmiPort">${jnp.rmiPort:8049}</property>
<property name="rmiBindAddress">${jnp.host:10.6.0.55}</property>
</bean>
hornetq-configuration.xml
<connectors>
<connector name="netty">
<factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
<param key="host" value="${hornetq.remoting.netty.host10.6.0.55}"/>
<param key="port" value="${hornetq.remoting.netty.port:5445}"/>
</connector>
<connector name="netty-throughput">
<factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
<param key="host" value="${hornetq.remoting.netty.host10.6.0.55}"/>
<param key="port" value="${hornetq.remoting.netty.batch.port:1098}"/>
<param key="batch-delay" value="50"/>
</connector>
</connectors>
<acceptors>
<acceptor name="netty">
<factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
<param key="host" value="${hornetq.remoting.netty.host:10.6.0.55}"/>
<param key="port" value="${hornetq.remoting.netty.port:5445}"/>
</acceptor>
<acceptor name="netty-throughput">
<factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
<param key="host" value="${hornetq.remoting.netty.host:10.6.0.55}"/>
<param key="port" value="${hornetq.remoting.netty.batch.port:1098}"/>
<param key="batch-delay" value="50"/>
<param key="direct-deliver" value="false"/>
</acceptor>
</acceptors>
hornetq-jms.xml
<queue name="CrawlerQueue">
<entry name="/queue/CrawlerQueue" />
</queue>
<queue name="ClassificationQueue">
<entry name="/queue/ClassificationQueue"/>
</queue>
Map connectionParams = new HashMap();
connectionParams.put(TransportConstants.PORT_PROP_NAME,5445);
connectionParams.put(TransportConstants.HOST_PROP_NAME,"your.public.host.name");
TransportConfiguration transportConfiguration = new TransportConfiguration("org.hornetq.core.remoting.impl.netty.NettyConnectorFactory", connectionParams);
ConnectionFactory cf = new HornetQConnectionFactory(transportConfiguration);
Queue crawlerQueue = new HornetQQueue("CrawlerQueue");Connection connection = cf.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);MessageProducer producer = session.createProducer(crawlerQueue);
MessageConsumer consumer = session.createConsumer(crawlerQueue);
connection.start();
TextMessage message = session.createTextMessage("This is an order");
producer.send(message);
TextMessage receivedMessage = (TextMessage) consumer.receive();
System.out.println("Got order: " + receivedMessage.getText());// output: Got order: This is an order
-Make sure that the hornetQ version on the server and on your client is the same. //2.1.2 doesn't like 2.2.2
-Also make sure that all the ports you are using is open on the public host