You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Robert Nicholson <ro...@gmail.com> on 2009/09/14 15:27:01 UTC

Use of jndi.properties with activemq?

When using org.apache.activemq.jndi.ActiveMQInitialContextFactory will  
it ever look for a local jndi.properties file?

I'm trying to get JMeter working with the JMSSampler and I keep  
getting a classcastexception when it does the lookup

>>> 2009/09/13 21:35:43 ERROR - jmeter.threads.JMeterThread: Test  
>>> failed!
>>> java.lang.ClassCastException:  
>>> org.apache.activemq.jndi.ReadOnlyContext
>>> cannot be cast to javax.jms.Queue






Re: Use of jndi.properties with activemq?

Posted by Rob Davies <ra...@gmail.com>.
On 15 Sep 2009, at 01:29, Robert Nicholson wrote:

> Ok I spotted one mistake and that was that I had receive queue and  
> not request queue populated in my Point to Point setup.
>
> Now I see messages in my queue. Eureka !!!
>
> On Sep 14, 2009, at 8:36 AM, Rob Davies wrote:
>
>>
>> On 14 Sep 2009, at 14:27, Robert Nicholson wrote:
>>
>>> When using org.apache.activemq.jndi.ActiveMQInitialContextFactory  
>>> will it ever look for a local jndi.properties file?
>>>
>>> I'm trying to get JMeter working with the JMSSampler and I keep  
>>> getting a classcastexception when it does the lookup
>>>
>>>>>> 2009/09/13 21:35:43 ERROR - jmeter.threads.JMeterThread: Test  
>>>>>> failed!
>>>>>> java.lang.ClassCastException:  
>>>>>> org.apache.activemq.jndi.ReadOnlyContext
>>>>>> cannot be cast to javax.jms.Queue
>>>
>>>
>>>
>>>
>>>
>>
>>
>> Yes - if it can find it on its classpath - see http://activemq.apache.org/jndi-support.html
>>
>> cheers,
>>
>> Rob
>>
>> Rob Davies
>> http://twitter.com/rajdavies
>> I work here: http://fusesource.com
>> My Blog: http://rajdavies.blogspot.com/
>> I'm writing this: http://www.manning.com/snyder/
>>
>>
>>
>>
>>
>


Great stuff! - and yes the finding of the properties file relies on  
InitialContext

cheers,

Rob Davies
http://twitter.com/rajdavies
I work here: http://fusesource.com
My Blog: http://rajdavies.blogspot.com/
I'm writing this: http://www.manning.com/snyder/






Re: Use of jndi.properties with activemq?

Posted by Robert Nicholson <ro...@gmail.com>.
Ok I spotted one mistake and that was that I had receive queue and not  
request queue populated in my Point to Point setup.

Now I see messages in my queue. Eureka !!!

On Sep 14, 2009, at 8:36 AM, Rob Davies wrote:

>
> On 14 Sep 2009, at 14:27, Robert Nicholson wrote:
>
>> When using org.apache.activemq.jndi.ActiveMQInitialContextFactory  
>> will it ever look for a local jndi.properties file?
>>
>> I'm trying to get JMeter working with the JMSSampler and I keep  
>> getting a classcastexception when it does the lookup
>>
>>>>> 2009/09/13 21:35:43 ERROR - jmeter.threads.JMeterThread: Test  
>>>>> failed!
>>>>> java.lang.ClassCastException:  
>>>>> org.apache.activemq.jndi.ReadOnlyContext
>>>>> cannot be cast to javax.jms.Queue
>>
>>
>>
>>
>>
>
>
> Yes - if it can find it on its classpath - see http://activemq.apache.org/jndi-support.html
>
> cheers,
>
> Rob
>
> Rob Davies
> http://twitter.com/rajdavies
> I work here: http://fusesource.com
> My Blog: http://rajdavies.blogspot.com/
> I'm writing this: http://www.manning.com/snyder/
>
>
>
>
>


Failover question (hangs appserver)

Posted by Leonard Gestrin <Le...@markettools.com>.
Hello, 
We are using activemq 5.2.0. Our webapp runs in tomcat 5. We don't use spring JMS support, however we do configure JMS listener class as a singleton in spring factory.

Recently, we configured failover capabilities as 

jms.broker.url=failover:(tcp://sfltlg-halsg3b1:61616,tcp://sfltlg-hlsag3b1:61616)?randomize=false&maxReconnectAttempts=1&initialReconnectDelay=30000

We set maxReconnectAttempts as 1 because we have our own connection retry mechanism that gets triggered on JMS exception; 
However, if both brokers are down, tomcat seems to hang and goes to 100% CPU. It appears as if client connection code tries to connect, fails and tries to reconnect right away. 
This behavior happens only if we use failover notation. If we revert back to 

jms.broker.url=://sfltlg-halsg3b1:61616 

and if we shutdown broker, webapp behaves OK -no memory/CPU spikes.

I can post our custom code, if it would help. 
Any suggestions what might be wrong with our configuration would be greatly appreciated.
Thanks
Leonard


Re: Use of jndi.properties with activemq?

Posted by Robert Nicholson <ro...@gmail.com>.
Why would I get this ClassCastException then? I do have a  
jndi.properties in a JNDI.jar that's in my classpath and here's it's  
contents

# use the following property to configure the default connector
#java.naming.provider.url = tcp://localhost:61616
java.naming.provider.url = vm://localhost
#connectionFactoryNames=ConnectionFactory

# register some queues in JNDI using the form
# queue.[jndiName] = [physicalName]
queue.QREQ = QUEUE_NAME

When I took at look at the source to  
jndi.ActiveMQInitialContextFactory I didn't see any support for  
jndi.properties so is this something that's support to  
InitialContextFactory?

The classcastexception happens in the following code

Object obj = context.lookup(getQueueConnectionFactory());
             if (!(obj instanceof QueueConnectionFactory)) {
                 String msg = "QueueConnectionFactory expected, but  
got "
                     + obj == null ? "null" :  obj.getClass().getName();
                 LOGGER.fatalError(msg);
                 throw new IllegalStateException(msg);
             }
             QueueConnectionFactory factory = (QueueConnectionFactory)  
obj;
             Queue queue = (Queue) context.lookup(getSendQueue());

The ContextFactory lookup goes ok but for some reason the queue lookup  
returns an ReadOnlyContext
and not a Queue.

On Sep 14, 2009, at 8:36 AM, Rob Davies wrote:

>
> On 14 Sep 2009, at 14:27, Robert Nicholson wrote:
>
>> When using org.apache.activemq.jndi.ActiveMQInitialContextFactory  
>> will it ever look for a local jndi.properties file?
>>
>> I'm trying to get JMeter working with the JMSSampler and I keep  
>> getting a classcastexception when it does the lookup
>>
>>>>> 2009/09/13 21:35:43 ERROR - jmeter.threads.JMeterThread: Test  
>>>>> failed!
>>>>> java.lang.ClassCastException:  
>>>>> org.apache.activemq.jndi.ReadOnlyContext
>>>>> cannot be cast to javax.jms.Queue
>>
>>
>>
>>
>>
>
>
> Yes - if it can find it on its classpath - see http://activemq.apache.org/jndi-support.html
>
> cheers,
>
> Rob
>
> Rob Davies
> http://twitter.com/rajdavies
> I work here: http://fusesource.com
> My Blog: http://rajdavies.blogspot.com/
> I'm writing this: http://www.manning.com/snyder/
>
>
>
>
>


Re: Use of jndi.properties with activemq?

Posted by Rob Davies <ra...@gmail.com>.
On 14 Sep 2009, at 14:27, Robert Nicholson wrote:

> When using org.apache.activemq.jndi.ActiveMQInitialContextFactory  
> will it ever look for a local jndi.properties file?
>
> I'm trying to get JMeter working with the JMSSampler and I keep  
> getting a classcastexception when it does the lookup
>
>>>> 2009/09/13 21:35:43 ERROR - jmeter.threads.JMeterThread: Test  
>>>> failed!
>>>> java.lang.ClassCastException:  
>>>> org.apache.activemq.jndi.ReadOnlyContext
>>>> cannot be cast to javax.jms.Queue
>
>
>
>
>


Yes - if it can find it on its classpath - see http://activemq.apache.org/jndi-support.html

cheers,

Rob

Rob Davies
http://twitter.com/rajdavies
I work here: http://fusesource.com
My Blog: http://rajdavies.blogspot.com/
I'm writing this: http://www.manning.com/snyder/