Thanks for your reply.
Here is my jndi.properties file:
java.naming.factory.initial =
org.apache.activemq.jndi.ActiveMQInitialContextFactory
java.naming.provider.url = tcp://localhost:61616
connectionFactoryNames = sampleFactory
queue.sampleQueue = MyQueue
userName=system
password=manager
-------------------------------------
Then i tried jndi lookup:
ConnectionFactory connectionFactory = null;
Context jndiContext = null;
connectionFactory = (ConnectionFactory)
jndiContext.lookup("connectionFactoryNames");
Getting the following exception if i tried to lookup using
key(connectionFactoryNames):
JNDI API lookup failed: javax.naming.NameNotFoundException:
connectionFactoryNames
JNDI API lookup failed: javax.naming.NameNotFoundException:
connectionFactoryNames
javax.naming.NameNotFoundException: connectionFactoryNames
at
org.apache.activemq.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java:225)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at com.sample.jms.JMSProducer.run(JMSProducer.java:50)
at java.lang.Thread.run(Thread.java:619)
Then i changed my code to get connection factory (lookup using value -
sampleFactory):
ConnectionFactory connectionFactory = null;
Context jndiContext = null;
connectionFactory = (ConnectionFactory) jndiContext.lookup("sampleFactory");
Its working fine. i am not understanding why it's happening... :-(
Gary Tully wrote:
>
> there are some hard coded defaults that make the sample code work, have a
> look at the source:
> http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/jndi/ActiveMQInitialContextFactory.java?view=markup
>
> In the properties file the connecitonFactoryNames property is commented
> out
> so the defaults are in effect.
>
> 2009/12/1 sbasani <[email protected]>
>
>>
>> Hi,
>>
>> I am new to ActiveMQ, I have gone through
>> http://activemq.apache.org/jndi-support.html and and gone through the
>> "Example Java code".
>>
>> First they specified
>> "connectionFactoryNames = connectionFactory, queueConnectionFactory,
>> topicConnectionFactry"
>> in jndi.properties. In this case as per the jndi key is
>> "connectionFactoryNames" and value is "connectionFactory,
>> queueConnectionFactory, topicConnectionFactry".
>>
>> But in "Example Java code" looking for "ConnectionFactory". Here
>> "ConnectionFactory" is value in jndi.properties it's not a key. But
>> example
>> program and everything working fine.
>>
>> connectionFactory =
>> (ConnectionFactory)jndiContext.lookup("ConnectionFactory");
>>
>> Please let me know... what is the logic here????
>>
>> Thanks.
>> --
>> View this message in context:
>> http://old.nabble.com/Confirm-the-correct-usage-of-%22connectionFactoryNames%22-tp26591001p26591001.html
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>
>>
>
>
> --
> http://blog.garytully.com
>
> Open Source Integration
> http://fusesource.com
>
>
--
View this message in context:
http://old.nabble.com/Confirm-the-correct-usage-of-%22connectionFactoryNames%22-tp26591001p26604016.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.