activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Tully <>
Subject Re: making queues findable from InitialContext.lookup(name)
Date Wed, 28 Oct 2009 11:28:26 GMT
think you may have to modify the source to achieve what you want here.

Is the initial context used for destination lookup parametrised?
I wonder if a solution would be to have the provider url contain the context
in its path.

so  something like: tcp://localhost:61616/dynamicQueues
such that the returned initial context is the "dynamicQueue" context. Then
lookup for any queue would succeed.

Again, this would require some code change to
org.apache.activemq.jndi.ActiveMQInitialContextFactory, and the same context
would not contain a factory reference. But the factory could be statically
configured I guess.

The problem with not having a separate dynamic context for queues and topics
is that they cannot be differentiated.

All patches/contributions welcome with thanks :-)

2009/10/27 Matthew Hixson <>

> Properties props = new Properties();
> props
> .setProperty
> (Context
> ,"org.apache.activemq.jndi.ActiveMQInitialContextFactory");
> props.setProperty(Context.PROVIDER_URL, "tcp://localhost:61616");
> InititalContext ic = new InitialContext(props));
> QueueConnectionFactory factory =
> (QueueConnectionFactory)ic.lookup("queueConnectionFactory");
> QueueSession jmsSession = jmsConnection.createQueueSession(false,
> javax.jms.Session.AUTO_ACKNOWLEDGE);
> Queue jmsqueue = (javax.jms.Queue)ic.lookup("dynamicQueues/" + QUEUE_NAME);
> I have the above code working to get a queue that is not defined in my
>  If I configure the queue in then I don't
> need the "dynamicQueues/" to proceed QUEUE_NAME.
>  What I'm doing is trying to replace a proprietary JMS server with
> ActiveMQ.  It looks as if this other software makes all of its queues
> available through the InitialContext.  So our existing code finds already
> existing queues in the JMS server just by doing:
> Queue jmsqueue = (javax.jms.Queue)ic.lookup(QUEUE_NAME);
> So it would be Very Convenient if I could get ActiveMQ to do the same thing
> so that we don't have to dredge through our codebase modifying every call to
> ic.lookup().
>  Is it possible to get that behavior through an ActiveMQ configuration?  If
> not then I suppose I could modify the ActiveMQ source to prepend
> "dynamicQueues/" to any queue name it is asked to lookup, but I'd rather not
> do that if its not necessary.
>  Thanks,
>  -M@


Open Source Integration

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