So this is much easier than you think and is what I have already said. If ActiveMQ is on localhost to OpenEJB this will do:
I am guessing you know how to create and access a simple stateless bean from OpenEJB: http://tomee.apache.org/examples-trunk/simple-stateless/README.html Create a simple EJB with one method - String[] hosts = aSimpleBean.getHosts(); In that method lookup and return the hosts final Set<String> hosts = new TreeSet<String>(); try { final InetAddress localhost = InetAddress.getLocalHost(); hosts.add(localhost.getHostAddress()); //Multi-homed final InetAddress[] all = InetAddress.getAllByName(localhost.getCanonicalHostName()); for (final InetAddress ip : all) { if (ip.isLinkLocalAddress() || ip.isMulticastAddress()) { continue; } final String ha = ip.getHostAddress(); if (!ha.replace("[", "").startsWith("2001:0:")) { //Filter Teredo hosts.add(ha); hosts.add(ip.getCanonicalHostName()); } } } catch (UnknownHostException e) { log.warning("Failed to list machine hosts", e); } return hosts.toArray(new String[hosts.size()]); Now get that bean, get the host list and use it to connect to ActiveMQ ctxProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory"); ctxProps.put(Context.PROVIDER_URL, "Try each host in a loop until you can connect!"); This is about as simple as it gets. All the code is open source. If ActiveMQ is remote then configure it's own discovery: http://activemq.apache.org/discovery.html -- View this message in context: http://openejb.979440.n4.nabble.com/slow-multicast-discovery-can-be-optimized-by-caching-server-tp4660726p4661030.html Sent from the OpenEJB Dev mailing list archive at Nabble.com.