activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthew Hixson <hix...@poindextrose.org>
Subject Re: making queues findable from InitialContext.lookup(name)
Date Wed, 28 Oct 2009 18:02:43 GMT
Hi Gary, that was a great idea, and I hadn't tried it yet, but  
ActiveMQ doesn't seem to like having anything else in the context  
path.  I get:

[WARN] TcpTransportFactory - path isn't a valid local location for  
TcpTransport to use <java.lang.NumberFormatException: For input  
string: "/dynamicQueues/">java.lang.NumberFormatException: For input  
string: "/dynamicQueues/"

and then it fails, of course, with:

javax.naming.NameNotFoundException: foo

The path I was using was

tcp://localhost:61616/dynamicQueues/

I tried it both with and without the trailing / and it didn't make a  
difference.

Any other ideas?
   Thanks,
    -M@

On Oct 28, 2009, at 4:28 AM, Gary Tully wrote:

> 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 <hixson@poindextrose.org>
>
>> Properties props = new Properties();
>> props
>> .setProperty
>> (Context
>> .INITIAL_CONTEXT_FACTORY
>> ,"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
>> jndi.properties.  If I configure the queue in jndi.properties 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@
>>
>
>
>
> -- 
> http://blog.garytully.com
>
> Open Source Integration
> http://fusesource.com


Mime
View raw message