HA-JNDI definitely works in a single machine cluster. I use it in this mode frequently and all of the HA-JNDI tests in the test suite do so as well.
You can differentiate the HA-JNDI servers either through service-bindings or by using multihome addresses. In either case, HA-JNDI should work properly.
You have to look up ConnectionFactory, not java:/ConnectionFactory. java:/ConnectionFactory is for the JVM invocation layer, which only works in the same JVM as the JMS server.
Unfortunalty it does not work without the 'java:/' prefix. I get
javax.naming.NameNotFoundException: ConnectionFactory not bound.
On a multihomed PC you have to change the HA-JNDI port by changing the jboss-service.xml in the conf directory and the cluster-service.xml in the deploy directory. So how can i look up the JMS ConnectionFactory on Node2 when Node1 is the masternode and contains the JMS service.
From the admin guide:
The HA-JMS client must obtain JMS connection factories from the HA-JNDI (the default port is 1100).
What am i missing?
How are you configuring your InitialContext? What are you setting as your javax.naming.provider.url?
Should be something like
assuming HA-JNDI is bound to 1100 on 1 and 1200 on 2.
I'm using SpringJMS for the plumming:
I just read that you can add environment properties to the template so i'll add the 2 nodes. But this is just a testenvironment, in real life we have 2 different machines, each hosting a node and running HA-JNDI on port 1100. My problem with adding env-props is that before i deploy my application in a real environment, i have to change these settings. My app is not a remote client but an app running in the cluster.
Dead end again. The env-props work for a different bean with the same name. I'm posting on the Spring forum as well.
Nevertheless, i hope that the cluster documentation in the admin guide will be more extensive, especially for different environments and JMS.
It almost works but the following line:
is a bit unclear on a multihomed machine. What do i need to fill in for node1 and node2? The name i gave the nodes? That doesn't work. Any suggestions?
Use your server addresses. For example -
Yep, that did it, i had to add some more Springplumming but it works fine now.
Thanks for the input.
One question. Can i also edit the jndi.properties for each JBoss server in a cluster instead of configuring my client application. It runs within the cluster so it shouldn't be aware of any HA-JNDI configuration.
If you change the jndi.properties within the server, you'll screw up the internal function of the server. You're much better off building up a Properties object and passing that to your InitialContext.
I did that and it worked until i tested the failover. It seems that my Spring Bean does not know how to reconnect on the failover node:
2006-05-09 14:51:18,512 WARN [org.jboss.mq.Connection] Connection failure, use javax.jms.Connection.setExceptionListener() to handle this error and reconnect
org.jboss.mq.SpyJMSException: Exiting on IOE; - nested throwable: (java.net.SocketException: Connection reset)
Caused by: java.net.SocketException: Connection reset
... 1 more
I made my own implementation using HASingletonSupport so the JMSSender only works on the masternode but this is a workaround for now.
Thanks for the input