You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by jworkman <jw...@oidev.com> on 2009/08/04 16:27:45 UTC

AMQ + Programmatic Creation of Destinations + Registration in JNDI

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);

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


Re: AMQ + Programmatic Creation of Destinations + Registration in JNDI

Posted by Joe Fernandez <jo...@ttmsolutions.com>.
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 <jw...@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 <jw...@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.


Re: AMQ + Programmatic Creation of Destinations + Registration in JNDI

Posted by jworkman <jw...@oidev.com>.
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 <jw...@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 <jw...@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-tp24809685p24810403.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: AMQ + Programmatic Creation of Destinations + Registration in JNDI

Posted by Dejan Bosanac <de...@nighttale.net>.
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 <jw...@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 <jw...@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.
>
>

Re: AMQ + Programmatic Creation of Destinations + Registration in JNDI

Posted by jworkman <jw...@oidev.com>.
I read it... I think the method of "dynamicQueues/" will try again. Just want
to know about cleanup though. How can I remove a dynamicQueue? 



James.Strachan wrote:
> 
> 2009/8/4 jworkman <jw...@oidev.com>:
>>
>> In the latter would the jms client call createQueue would that be up to
>> the
>> server?
>> If up to the server, then how would the calling client access that queue?
> 
> Please read the FAQ I pointed you at.
> http://activemq.apache.org/how-do-i-create-new-destinations.html
> 
> The short answer is - it just works.
> 
> -- 
> 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-tp24809685p24811420.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: AMQ + Programmatic Creation of Destinations + Registration in JNDI

Posted by James Strachan <ja...@gmail.com>.
2009/8/4 jworkman <jw...@oidev.com>:
>
> In the latter would the jms client call createQueue would that be up to the
> server?
> If up to the server, then how would the calling client access that queue?

Please read the FAQ I pointed you at.
http://activemq.apache.org/how-do-i-create-new-destinations.html

The short answer is - it just works.

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/

Re: AMQ + Programmatic Creation of Destinations + Registration in JNDI

Posted by jworkman <jw...@oidev.com>.
In the latter would the jms client call createQueue would that be up to the
server? 
If up to the server, then how would the calling client access that queue?


James.Strachan wrote:
> 
> 2009/8/4 jworkman <jw...@oidev.com>:
>>
>>
>>
>> James.Strachan wrote:
>>>
>>> 2009/8/4 jworkman <jw...@oidev.com>:
>>>>
>>>> I am not sure I follow... When I do
>>>> ctx.lookup("dyanmicQueues/whatever")
>>>> what
>>>> will this do? Create a queue if one does not exist in the destination
>>>> amq
>>>> server?
>>>
>>> Yes, see this FAQ entry...
>>> http://activemq.apache.org/how-do-i-create-new-destinations.html
>>>
>>>
>>>> What is happening currently on the remote (calling) client: I can
>>>> access
>>>> the
>>>> factory and create the connection with a session okay, but when I try
>>>> to
>>>> do
>>>> a lookup for the domain/queue (which I explicitly created by calling
>>>> createQueue("domain/queue") on destination amq server) I get queue not
>>>> found.
>>>>
>>>> Is prepending dynamicQueues/ the only way around?
>>>
>>> use the "dynamicQueues/whatever" to look up the Queue object in JNDI
>>> (which will map to the "whatever" queue in ActiveMQ.
>>>
>>>
>>
>> So in regards to the above does this mean that whatever has to be
>> regsitered
>> in activemq or will it be so automatically if whatever did not exist? So
>> in
>> theory, I could call "dyanmicQueues/bob or dynamicQueues/frank" and these
>> would get created automatically?
> 
> Yes, dynamicQueues/foo means you can use any value of "foo" at runtime
> and it just works - a Queue/Topic will be created for you
> automatically.
> 
> Though if you are calling createQueue(String) or createTopic(String)
> on a Session, you don't need to do anything with JNDI at all.
> 
> -- 
> 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-tp24809685p24810651.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: AMQ + Programmatic Creation of Destinations + Registration in JNDI

Posted by James Strachan <ja...@gmail.com>.
2009/8/4 jworkman <jw...@oidev.com>:
>
>
>
> James.Strachan wrote:
>>
>> 2009/8/4 jworkman <jw...@oidev.com>:
>>>
>>> I am not sure I follow... When I do ctx.lookup("dyanmicQueues/whatever")
>>> what
>>> will this do? Create a queue if one does not exist in the destination amq
>>> server?
>>
>> Yes, see this FAQ entry...
>> http://activemq.apache.org/how-do-i-create-new-destinations.html
>>
>>
>>> What is happening currently on the remote (calling) client: I can access
>>> the
>>> factory and create the connection with a session okay, but when I try to
>>> do
>>> a lookup for the domain/queue (which I explicitly created by calling
>>> createQueue("domain/queue") on destination amq server) I get queue not
>>> found.
>>>
>>> Is prepending dynamicQueues/ the only way around?
>>
>> use the "dynamicQueues/whatever" to look up the Queue object in JNDI
>> (which will map to the "whatever" queue in ActiveMQ.
>>
>>
>
> So in regards to the above does this mean that whatever has to be regsitered
> in activemq or will it be so automatically if whatever did not exist? So in
> theory, I could call "dyanmicQueues/bob or dynamicQueues/frank" and these
> would get created automatically?

Yes, dynamicQueues/foo means you can use any value of "foo" at runtime
and it just works - a Queue/Topic will be created for you
automatically.

Though if you are calling createQueue(String) or createTopic(String)
on a Session, you don't need to do anything with JNDI at all.

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/

Re: AMQ + Programmatic Creation of Destinations + Registration in JNDI

Posted by jworkman <jw...@oidev.com>.


James.Strachan wrote:
> 
> 2009/8/4 jworkman <jw...@oidev.com>:
>>
>> I am not sure I follow... When I do ctx.lookup("dyanmicQueues/whatever")
>> what
>> will this do? Create a queue if one does not exist in the destination amq
>> server?
> 
> Yes, see this FAQ entry...
> http://activemq.apache.org/how-do-i-create-new-destinations.html
> 
> 
>> What is happening currently on the remote (calling) client: I can access
>> the
>> factory and create the connection with a session okay, but when I try to
>> do
>> a lookup for the domain/queue (which I explicitly created by calling
>> createQueue("domain/queue") on destination amq server) I get queue not
>> found.
>>
>> Is prepending dynamicQueues/ the only way around?
> 
> use the "dynamicQueues/whatever" to look up the Queue object in JNDI
> (which will map to the "whatever" queue in ActiveMQ.
> 
> 

So in regards to the above does this mean that whatever has to be regsitered
in activemq or will it be so automatically if whatever did not exist? So in
theory, I could call "dyanmicQueues/bob or dynamicQueues/frank" and these
would get created automatically?



> 
> If you don't want to use JNDI to lookup destinations, just call
> createQueue(String) - then there is no need to register anything in
> JNDI for queue/topics,  other than your ConnectionFactory - of which
> you'll probably only need a single one.
> 
> -- 
> 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-tp24809685p24810463.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: AMQ + Programmatic Creation of Destinations + Registration in JNDI

Posted by James Strachan <ja...@gmail.com>.
2009/8/4 jworkman <jw...@oidev.com>:
>
> I am not sure I follow... When I do ctx.lookup("dyanmicQueues/whatever") what
> will this do? Create a queue if one does not exist in the destination amq
> server?

Yes, see this FAQ entry...
http://activemq.apache.org/how-do-i-create-new-destinations.html


> What is happening currently on the remote (calling) client: I can access the
> factory and create the connection with a session okay, but when I try to do
> a lookup for the domain/queue (which I explicitly created by calling
> createQueue("domain/queue") on destination amq server) I get queue not
> found.
>
> Is prepending dynamicQueues/ the only way around?

use the "dynamicQueues/whatever" to look up the Queue object in JNDI
(which will map to the "whatever" queue in ActiveMQ.

If you don't want to use JNDI to lookup destinations, just call
createQueue(String) - then there is no need to register anything in
JNDI for queue/topics,  other than your ConnectionFactory - of which
you'll probably only need a single one.

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/

Re: AMQ + Programmatic Creation of Destinations + Registration in JNDI

Posted by jworkman <jw...@oidev.com>.
I am not sure I follow... When I do ctx.lookup("dyanmicQueues/whatever") what
will this do? Create a queue if one does not exist in the destination amq
server?

What is happening currently on the remote (calling) client: I can access the
factory and create the connection with a session okay, but when I try to do
a lookup for the domain/queue (which I explicitly created by calling
createQueue("domain/queue") on destination amq server) I get queue not
found. 

Is prepending dynamicQueues/ the only way around?



James.Strachan wrote:
> 
> 2009/8/4 jworkman <jw...@oidev.com>:
>>
>> Yes I read the secion, but it explains about adding it to the
>> jndi.properties
>> file, which I can do for predefined ones but not ones created in memory.
>>
>> dynamicQueues/ don't seem to work when I try to connect from an external
>> client.
> 
> The JNDI provider is local to the client - its not a JNDI server; it
> creates destinations in memory of the JMS client process.
> 
> What happens when you try use the following properties file in your
> client?
> 
>> 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 <jw...@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.
>>
>>
> 
> 
> 
> -- 
> 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-tp24809685p24810211.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: AMQ + Programmatic Creation of Destinations + Registration in JNDI

Posted by James Strachan <ja...@gmail.com>.
2009/8/4 jworkman <jw...@oidev.com>:
>
> Yes I read the secion, but it explains about adding it to the jndi.properties
> file, which I can do for predefined ones but not ones created in memory.
>
> dynamicQueues/ don't seem to work when I try to connect from an external
> client.

The JNDI provider is local to the client - its not a JNDI server; it
creates destinations in memory of the JMS client process.

What happens when you try use the following properties file in your client?

> 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 <jw...@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.
>
>



-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/

Re: AMQ + Programmatic Creation of Destinations + Registration in JNDI

Posted by jworkman <jw...@oidev.com>.
Yes I read the secion, but it explains about adding it to the jndi.properties
file, which I can do for predefined ones but not ones created in memory. 

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 <jw...@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.


Re: AMQ + Programmatic Creation of Destinations + Registration in JNDI

Posted by James Strachan <ja...@gmail.com>.
2009/8/4 jworkman <jw...@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/