activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexandre Léveillé <>
Subject Defining a local address and local port *range* for SSL
Date Wed, 30 Jun 2010 22:09:41 GMT
Hi all,

Short version : I want to define a local address and local port *range* in
the file.  Something like java.naming.provider.url = ssl:// That didn't work (obviously). Is
there any way to specify a port range, instead of a port number?

Long version :


I have an AMQ client which lookups a ConnectionFactory using JNDI and the
InitialContext. Here's my file, trimmed down:


java.naming.factory.initial =

# use the following property to configure the default connector
java.naming.provider.url = ssl://

# register some topics in JNDI
topic.MyTopic = example.MyTopic

This works great, I can get the client to open a SSL socket on local port

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://
java.naming.provider.url = ssl://,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!

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message