If you want to create queues & topics (JMS administered objects) in code and
then later be able to have your clients locate them via jndi lookups, then
one thing you may want to consider is to use a LDAP directory server (e.g.,
Apache DS) as your centralized JNDI server. The two things that greatly
facilitate this are a) all AMQ's administered objects are 'Referenceable'
and b) the 'com.sun.jndi.ldap' package, which is included in Java 5+. 

With this approach, you don't have to rely on the jndi.properties files for
locating the administered objects; all the objects (i.e., object references)
are maintained in one central and secure repository. Apache DS also has a
wicked LDAP GUI client ;) 

You may even be able to develop a AMQ broker plugin that does this for you.
For example, the  createQueue method subsequently invokes the addDestination
broker plugin method, which would then add a corresponding object reference
to to the DS. 

Food for thought...

Joe
http://www.ttmsolutions.com 



jworkman wrote:
> 
> Hi Dejan - the below example will work fine, however, it doesn't solve our
> need. We need to be able to create queues and topics programmatically
> (createQueue) and I want to avoid having to write something out to
> jndi.properties to do this. Also, most of our lookups currently have "/"'s
> in the name and I found you can't easily do this, like: queue/domain/qname
> = some/physical/name 
> 
> 
> A little more background: we were using jboss mq to handle messaging, but
> after some debate decided to move away. Jboss would force us to write out
> a mbean xml containing the queue or topic and that would be accessible in
> jndi lookups. I really like ActiveMQ but as I have said we have to be able
> to create queues & topics in code and support the ability to find them by
> doing jndi lookups -- without having to manually bounce the server or
> otherwise append to some properties file. 
> 
> Hope that helps in clarity...
> 
> 
> Dejan Bosanac wrote:
>> 
>> Hi Jason,
>> 
>> can you try specifying
>> 
>> queue.MyQueue = domainname/queuename
>> 
>> in your jndi.properties
>> 
>> and use
>> 
>> queue = (Queue) ctx.lookup("MyQueue");
>> 
>> in your Java app. The same should work for topics as well.
>> 
>> 
>> Cheers
>> --
>> Dejan Bosanac
>> 
>> Open Source Integration - http://fusesource.com/
>> ActiveMQ in Action - http://www.manning.com/snyder/
>> Blog - http://www.nighttale.net
>> 
>> 
>> On Tue, Aug 4, 2009 at 4:42 PM, jworkman <jwork...@oidev.com> wrote:
>> 
>>>
>>> Yes I read the section, but it explains about adding it to the
>>> jndi.properties file, which I can do for predefined ones but not ones
>>> created in memory (I need something similar to session.createQueue but
>>> accessible through jndi lookups to keep the api portable).
>>>
>>> dynamicQueues/ don't seem to work when I try to connect from an external
>>> client.
>>>
>>> My jndi properties:
>>>
>>>
>>> java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory
>>> java.naming.provider.url=tcp://xxxxxx:61616
>>> java.naming.referral=throw
>>> java.naming.factory.object=ConnectionFactory
>>>
>>> Queue name I am trying to create:
>>>
>>> domainname/queuename
>>>
>>>
>>> Thanks for your assistance...
>>>
>>> Jason
>>>
>>>
>>> James.Strachan wrote:
>>> >
>>> > 2009/8/4 jworkman <jwork...@oidev.com>:
>>> >>
>>> >> I really need help, I am struggling to create queues and topics in
>>> >> ActiveMQ
>>> >> and have them accessible from JNDI lookups. I need this
>>> >> creation/registration to be done without bringing the server down,
>>> and
>>> >> done
>>> >> without manual configuration.
>>> >>
>>> >> Something like:
>>> >>
>>> >> //create the jndi context
>>> >> InitialContext jndiContext = new
>>> InitialContext(loadConnectionProps());
>>> >>
>>> >> // Create a ConnectionFactory
>>> >> ConnectionFactory connectionFactory = (ConnectionFactory)
>>> >>
>>> jndiContext.lookup(loadConnectionProps().getProperty(Context.OBJECT_FACTORIES));
>>> >>
>>> >> // Create a Connection
>>> >> Connection connection = connectionFactory.createConnection();
>>> >>
>>> >> // Create a Session
>>> >> Session session = connection.createSession(false,
>>> >> Session.AUTO_ACKNOWLEDGE);
>>> >>
>>> >> // Create the destination (Topic or Queue)
>>> >> session.createQueue(qname);
>>> >>
>>> >> ************this below doesn't work***********
>>> >>
>>> >> //get the topic from jndi
>>> >> topic = (Topic) ctx.lookup(name);
>>> >
>>> > What names are you looking up?
>>> >
>>> > Did you read the section on "Dynamically creating destinations" here?
>>> > http://activemq.apache.org/jndi-support.html
>>> >
>>> >
>>> > --
>>> > James
>>> > -------
>>> > http://macstrac.blogspot.com/
>>> >
>>> > Open Source Integration
>>> > http://fusesource.com/
>>> >
>>> >
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/AMQ-%2B-Programmatic-Creation-of-Destinations-%2B-Registration-in-JNDI-tp24809685p24809919.html
>>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>>
>>>
>> 
>> 
>> -----
>> Dejan Bosanac
>> 
>> Open Source Integration - http://fusesource.com/
>> ActiveMQ in Action - http://www.manning.com/snyder/
>> Blog - http://www.nighttale.net
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/AMQ-%2B-Programmatic-Creation-of-Destinations-%2B-Registration-in-JNDI-tp24809685p24867308.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Reply via email to