Hi all,
Short version : I want to define a local address and local port *range* in
the jndi.properties file. Something like java.naming.provider.url = ssl://
10.1.1.123:61617/localhost:60140-60150. That didn't work (obviously). Is
there any way to specify a port range, instead of a port number?
Long version :
Context:
I have an AMQ client which lookups a ConnectionFactory using JNDI and the
InitialContext. Here's my jndi.properties file, trimmed down:
# START SNIPPET: jndi
java.naming.factory.initial =
org.apache.activemq.jndi.ActiveMQInitialContextFactory
userName=user
password=pass
# use the following property to configure the default connector
java.naming.provider.url = ssl://10.1.1.123:61617/localhost:60606
# register some topics in JNDI
topic.MyTopic = example.MyTopic
# END SNIPPET: jndi
This works great, I can get the client to open a SSL socket on local port
60606.
My problem :
In the future, I may have more than one client running on that machine.
After a few tests, I found out that createConnection() uses an arbitrary
port number when the port specified (60606) is already in use. The security
on the machine where the client is running is pretty tight; ports need to be
open as they are all (almost) closed by default. Therefore,
createConnection() using arbitrary port numbers wouldn't work.
Question :
Can I specify a local port range, instead a local port number, in the
provider URI? Something like :
java.naming.provider.url = ssl://10.1.1.123:61617/localhost:60140-60150
java.naming.provider.url = ssl://
10.1.1.123:61617/localhost:60140,localhost:60141,localhost:60142,.....
If that's impossible, is the following solution the "next best thing" ?
1. Define minPort and maxPort in a property file / xml file.
2. Have the code read the port range
3. Have the code check which ports are free.
4. Create an environment hashtable and do something like
: env.put("java.naming.provider.url", port_to_use)
5. Instantiate the jndiContext with the properties that were just set :
jndiContext = new InitialContext(environment );
I am using :
- AMQ 5.3.2
- JRE 1.6.0_07 & JDK 1.6.0_20
- No application server (I'm still confused that the JNDI lookup works
without Tomcat or Glassfish running, but that's another topic altogether)
- At the moment, the clients and broker run on WinXP SP3 (we are testing AMQ
applicability as a solution)
Thank you for your input!
Alexandre