You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by wallace <wa...@yahoo.com> on 2007/04/09 01:00:36 UTC
Re: JBoss integration and lookup of connection factories.
I can make the jndi lookup working within jboss j2ee container. But jndi
apparently does not work from a single standalone client, when accessing
jndi of jboss.
For example,
Properties env2 = new Properties();
......
env2.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
env2.put(Context.PROVIDER_URL, "jnp://localhost:1099");
InitialContext jndi2 = new InitialContext(env2);
TopicConnectionFactory connectionFactory =
(javax.jms.TopicConnectionFactory)
jndi2.lookup("java:activemq/TopicConnectionFactory");
The code always returns name not found exception. Has anyone ever made it
work in standalone client?
-Wallace Wong
tbaker73 wrote:
>
> James, could you please provide an example of the connection factory entry
> to add under <connection-factories> in a -ds.xml file that would
> accomplish what you suggest? How would it differ from this entry?
> <tx-connection-factory>
> <jndi-name>activemq/QueueConnectionFactory</jndi-name>
> <xa-transaction/>
> <track-connection-by-tx/>
> <rar-name>activemq-ra.rar</rar-name>
>
> <connection-definition>javax.jms.QueueConnectionFactory</connection-definition>
> <ServerUrl>vm://localhost</ServerUrl>
> <UserName>sa</UserName>
> <Password></Password>
> <min-pool-size>1</min-pool-size>
> <max-pool-size>200</max-pool-size>
> <blocking-timeout-millis>30000</blocking-timeout-millis>
> <idle-timeout-minutes>3</idle-timeout-minutes>
> </tx-connection-factory>
>
>
> James.Strachan wrote:
>>
>>
>> You'll need to setup a regular JMS connection and any destination
>> objects you want in JNDI somewhere. Using JBoss's JNDI provider could
>> well work fine though - just make sure its actually normal JMS client
>> objects (ConnectionFactory & destinations) - and not RA stuff. Also
>> make sure the J2EE server and your stand alone client are using the
>> exact same ActiveMQ jars since its gonna be using Java serialization
>> to transmit the Java objects in JNDI
>> --
>>
>> James
>> -------
>> http://radio.weblogs.com/0112098/
>>
>>
>
>
--
View this message in context: http://www.nabble.com/JBoss-integration-and-lookup-of-connection-factories.-tf3061463s2354.html#a9896459
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: JBoss integration and lookup of connection factories.
Posted by James Strachan <ja...@gmail.com>.
On 4/10/07, wallace <wa...@yahoo.com> wrote:
>
> Thanks for response.
>
> This works for me too. But it is a very big limitation to require the client
> to hard code the physical queue name (in your example, example.MyQueue). It
> defeats the purpose of jndi.
The properties file can be put in the jndi.properties on the classpath
as mentioned in the documentation; so there's no need to use the
actual physical queue names in your Java code if you want.
http://activemq.apache.org/jndi-support.html
--
James
-------
http://radio.weblogs.com/0112098/
Re: JBoss integration and lookup of connection factories.
Posted by wallace <wa...@yahoo.com>.
Thanks for response.
This works for me too. But it is a very big limitation to require the client
to hard code the physical queue name (in your example, example.MyQueue). It
defeats the purpose of jndi. The client should only need to know the jndi
name. So no code change is necessary when the server change the physical
name.
It is now a funny situation. If I lookup from activemq jndi, I have to pass
in the physical name. I can actually lookup the topic name from jboss jndi.
But if I lookup from jboss jndi, connection factory will return null (It
looks like a bug to me as context list binding returns the correct class
name). Neither of the jndi server gets me both things right.
Thanks for your help though.
-Wallace
rachit goel wrote:
>
> @ WALLACE
>
> Yes i have successfully implemented the jms thing rom core java
> application.
>
> if u use
>
> Properties Initialcontext_props = null;
>
> queueName = "example.MyQueue";
>
> Initialcontext_props = new Properties();
> Initialcontext_props.put(Context.INITIAL_CONTEXT_FACTORY ,
> "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
> Initialcontext_props.put(Context.PROVIDER_URL, "tcp://app-minim:61616");
>
> Initialcontext_props.put("connectionFactoryNames","jms/QueuecConFactory");
> Initialcontext_props.put("queue.MyQueue" , queueName);
>
> jndiContext = new InitialContext(Initialcontext_props);
>
>
> it will work just fine . Also make sure u have addedd the active-mq's jar
> file in ur classpath.
>
>
>
> wallace wrote:
>>
>> I can make the jndi lookup working within jboss j2ee container. But jndi
>> apparently does not work from a single standalone client, when accessing
>> jndi of jboss.
>>
>> For example,
>> Properties env2 = new Properties();
>> ......
>> env2.put(Context.INITIAL_CONTEXT_FACTORY,
>> "org.jnp.interfaces.NamingContextFactory");
>> env2.put(Context.PROVIDER_URL, "jnp://localhost:1099");
>> InitialContext jndi2 = new InitialContext(env2);
>>
>> TopicConnectionFactory connectionFactory =
>> (javax.jms.TopicConnectionFactory)
>> jndi2.lookup("java:activemq/TopicConnectionFactory");
>>
>> The code always returns name not found exception. Has anyone ever made it
>> work in standalone client?
>>
>> -Wallace Wong
>>
>>
>>
>> tbaker73 wrote:
>>>
>>> James, could you please provide an example of the connection factory
>>> entry to add under <connection-factories> in a -ds.xml file that would
>>> accomplish what you suggest? How would it differ from this entry?
>>> <tx-connection-factory>
>>> <jndi-name>activemq/QueueConnectionFactory</jndi-name>
>>> <xa-transaction/>
>>> <track-connection-by-tx/>
>>> <rar-name>activemq-ra.rar</rar-name>
>>>
>>> <connection-definition>javax.jms.QueueConnectionFactory</connection-definition>
>>> <ServerUrl>vm://localhost</ServerUrl>
>>> <UserName>sa</UserName>
>>> <Password></Password>
>>> <min-pool-size>1</min-pool-size>
>>> <max-pool-size>200</max-pool-size>
>>> <blocking-timeout-millis>30000</blocking-timeout-millis>
>>> <idle-timeout-minutes>3</idle-timeout-minutes>
>>> </tx-connection-factory>
>>>
>>>
>>> James.Strachan wrote:
>>>>
>>>>
>>>> You'll need to setup a regular JMS connection and any destination
>>>> objects you want in JNDI somewhere. Using JBoss's JNDI provider could
>>>> well work fine though - just make sure its actually normal JMS client
>>>> objects (ConnectionFactory & destinations) - and not RA stuff. Also
>>>> make sure the J2EE server and your stand alone client are using the
>>>> exact same ActiveMQ jars since its gonna be using Java serialization
>>>> to transmit the Java objects in JNDI
>>>> --
>>>>
>>>> James
>>>> -------
>>>> http://radio.weblogs.com/0112098/
>>>>
>>>>
>>>
>>>
>>
>>
>
>
--
View this message in context: http://www.nabble.com/JBoss-integration-and-lookup-of-connection-factories.-tf3061463s2354.html#a9922505
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: JBoss integration and lookup of connection factories.
Posted by rachit goel <pa...@yahoo.co.uk>.
well u can get them from user at run time . like ome sort of preferences or
key - value pair properties file.
wallace wrote:
>
> Thanks for response.
>
> This works for me too. But it is a very big limitation to require the
> client to hard code the physical queue name (in your example,
> example.MyQueue). It defeats the purpose of jndi. The client should only
> need to know the jndi name. So no code change is necessary when the server
> change the physical name.
>
> It is now a funny situation. If I lookup from activemq jndi, I have to
> pass in the physical name. I can actually lookup the topic name from jboss
> jndi. But if I lookup from jboss jndi, connection factory will return null
> (It looks like a bug to me as context list binding returns the correct
> class name). Neither of the jndi server gets me both things right.
>
> Thanks for your help though.
> -Wallace
>
>
> rachit goel wrote:
>>
>> @ WALLACE
>>
>> Yes i have successfully implemented the jms thing rom core java
>> application.
>>
>> if u use
>>
>> Properties Initialcontext_props = null;
>>
>> queueName = "example.MyQueue";
>>
>> Initialcontext_props = new Properties();
>> Initialcontext_props.put(Context.INITIAL_CONTEXT_FACTORY ,
>> "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
>> Initialcontext_props.put(Context.PROVIDER_URL,
>> "tcp://app-minim:61616");
>>
>> Initialcontext_props.put("connectionFactoryNames","jms/QueuecConFactory");
>> Initialcontext_props.put("queue.MyQueue" , queueName);
>>
>> jndiContext = new InitialContext(Initialcontext_props);
>>
>>
>> it will work just fine . Also make sure u have addedd the active-mq's jar
>> file in ur classpath.
>>
>>
>>
>> wallace wrote:
>>>
>>> I can make the jndi lookup working within jboss j2ee container. But jndi
>>> apparently does not work from a single standalone client, when accessing
>>> jndi of jboss.
>>>
>>> For example,
>>> Properties env2 = new Properties();
>>> ......
>>> env2.put(Context.INITIAL_CONTEXT_FACTORY,
>>> "org.jnp.interfaces.NamingContextFactory");
>>> env2.put(Context.PROVIDER_URL, "jnp://localhost:1099");
>>> InitialContext jndi2 = new InitialContext(env2);
>>>
>>> TopicConnectionFactory connectionFactory =
>>> (javax.jms.TopicConnectionFactory)
>>> jndi2.lookup("java:activemq/TopicConnectionFactory");
>>>
>>> The code always returns name not found exception. Has anyone ever made
>>> it work in standalone client?
>>>
>>> -Wallace Wong
>>>
>>>
>>>
>>> tbaker73 wrote:
>>>>
>>>> James, could you please provide an example of the connection factory
>>>> entry to add under <connection-factories> in a -ds.xml file that would
>>>> accomplish what you suggest? How would it differ from this entry?
>>>> <tx-connection-factory>
>>>> <jndi-name>activemq/QueueConnectionFactory</jndi-name>
>>>> <xa-transaction/>
>>>> <track-connection-by-tx/>
>>>> <rar-name>activemq-ra.rar</rar-name>
>>>>
>>>> <connection-definition>javax.jms.QueueConnectionFactory</connection-definition>
>>>> <ServerUrl>vm://localhost</ServerUrl>
>>>> <UserName>sa</UserName>
>>>> <Password></Password>
>>>> <min-pool-size>1</min-pool-size>
>>>> <max-pool-size>200</max-pool-size>
>>>> <blocking-timeout-millis>30000</blocking-timeout-millis>
>>>> <idle-timeout-minutes>3</idle-timeout-minutes>
>>>> </tx-connection-factory>
>>>>
>>>>
>>>> James.Strachan wrote:
>>>>>
>>>>>
>>>>> You'll need to setup a regular JMS connection and any destination
>>>>> objects you want in JNDI somewhere. Using JBoss's JNDI provider could
>>>>> well work fine though - just make sure its actually normal JMS client
>>>>> objects (ConnectionFactory & destinations) - and not RA stuff. Also
>>>>> make sure the J2EE server and your stand alone client are using the
>>>>> exact same ActiveMQ jars since its gonna be using Java serialization
>>>>> to transmit the Java objects in JNDI
>>>>> --
>>>>>
>>>>> James
>>>>> -------
>>>>> http://radio.weblogs.com/0112098/
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
--
View this message in context: http://www.nabble.com/JBoss-integration-and-lookup-of-connection-factories.-tf3061463s2354.html#a9932985
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: JBoss integration and lookup of connection factories.
Posted by wallace <wa...@yahoo.com>.
Thanks for response.
This works for me too. But it is a very big limitation to require the client
to hard code the physical queue name (in your example, example.MyQueue). It
defeats the purpose of jndi. The client should only need to know the jndi
name. So no code change is necessary when the server change the physical
name.
It is now a funny situation. If I lookup from activemq jndi, I have to pass
in the physical name. I can actually lookup the topic name from jboss jndi.
But if I lookup from jboss jndi, connection factory will return null (It
looks like a bug to me as context list binding returns the correct class
name). Neither of the jndi server gets me both things right.
Thanks for your help though.
-Wallace
rachit goel wrote:
>
> @ WALLACE
>
> Yes i have successfully implemented the jms thing rom core java
> application.
>
> if u use
>
> Properties Initialcontext_props = null;
>
> queueName = "example.MyQueue";
>
> Initialcontext_props = new Properties();
> Initialcontext_props.put(Context.INITIAL_CONTEXT_FACTORY ,
> "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
> Initialcontext_props.put(Context.PROVIDER_URL, "tcp://app-minim:61616");
>
> Initialcontext_props.put("connectionFactoryNames","jms/QueuecConFactory");
> Initialcontext_props.put("queue.MyQueue" , queueName);
>
> jndiContext = new InitialContext(Initialcontext_props);
>
>
> it will work just fine . Also make sure u have addedd the active-mq's jar
> file in ur classpath.
>
>
>
> wallace wrote:
>>
>> I can make the jndi lookup working within jboss j2ee container. But jndi
>> apparently does not work from a single standalone client, when accessing
>> jndi of jboss.
>>
>> For example,
>> Properties env2 = new Properties();
>> ......
>> env2.put(Context.INITIAL_CONTEXT_FACTORY,
>> "org.jnp.interfaces.NamingContextFactory");
>> env2.put(Context.PROVIDER_URL, "jnp://localhost:1099");
>> InitialContext jndi2 = new InitialContext(env2);
>>
>> TopicConnectionFactory connectionFactory =
>> (javax.jms.TopicConnectionFactory)
>> jndi2.lookup("java:activemq/TopicConnectionFactory");
>>
>> The code always returns name not found exception. Has anyone ever made it
>> work in standalone client?
>>
>> -Wallace Wong
>>
>>
>>
>> tbaker73 wrote:
>>>
>>> James, could you please provide an example of the connection factory
>>> entry to add under <connection-factories> in a -ds.xml file that would
>>> accomplish what you suggest? How would it differ from this entry?
>>> <tx-connection-factory>
>>> <jndi-name>activemq/QueueConnectionFactory</jndi-name>
>>> <xa-transaction/>
>>> <track-connection-by-tx/>
>>> <rar-name>activemq-ra.rar</rar-name>
>>>
>>> <connection-definition>javax.jms.QueueConnectionFactory</connection-definition>
>>> <ServerUrl>vm://localhost</ServerUrl>
>>> <UserName>sa</UserName>
>>> <Password></Password>
>>> <min-pool-size>1</min-pool-size>
>>> <max-pool-size>200</max-pool-size>
>>> <blocking-timeout-millis>30000</blocking-timeout-millis>
>>> <idle-timeout-minutes>3</idle-timeout-minutes>
>>> </tx-connection-factory>
>>>
>>>
>>> James.Strachan wrote:
>>>>
>>>>
>>>> You'll need to setup a regular JMS connection and any destination
>>>> objects you want in JNDI somewhere. Using JBoss's JNDI provider could
>>>> well work fine though - just make sure its actually normal JMS client
>>>> objects (ConnectionFactory & destinations) - and not RA stuff. Also
>>>> make sure the J2EE server and your stand alone client are using the
>>>> exact same ActiveMQ jars since its gonna be using Java serialization
>>>> to transmit the Java objects in JNDI
>>>> --
>>>>
>>>> James
>>>> -------
>>>> http://radio.weblogs.com/0112098/
>>>>
>>>>
>>>
>>>
>>
>>
>
>
--
View this message in context: http://www.nabble.com/JBoss-integration-and-lookup-of-connection-factories.-tf3061463s2354.html#a9922499
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: JBoss integration and lookup of connection factories.
Posted by wallace <wa...@yahoo.com>.
Thanks for response.
This works for me too. But it is a very big limitation to require the client
to hard code the physical queue name (in your example, example.MyQueue). It
defeats the purpose of jndi. The client should only need to know the jndi
name. So no code change is necessary when the server change the physical
name.
It is now a funny situation. If I lookup from activemq jndi, I have to pass
in the physical name. I can actually lookup the topic name from jboss jndi.
But if I lookup from jboss jndi, connection factory will return null (It
looks like a bug to me as context list binding returns the correct class
name). Neither of the jndi server gets me both things right.
Thanks for your help though.
-Wallace
--
View this message in context: http://www.nabble.com/JBoss-integration-and-lookup-of-connection-factories.-tf3061463s2354.html#a9922506
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: JBoss integration and lookup of connection factories.
Posted by rachit goel <pa...@yahoo.co.uk>.
@ WALLACE
Yes i have successfully implemented the jms thing rom core java
application.
if u use
Properties Initialcontext_props = null;
queueName = "example.MyQueue";
Initialcontext_props = new Properties();
Initialcontext_props.put(Context.INITIAL_CONTEXT_FACTORY ,
"org.apache.activemq.jndi.ActiveMQInitialContextFactory");
Initialcontext_props.put(Context.PROVIDER_URL, "tcp://app-minim:61616");
Initialcontext_props.put("connectionFactoryNames","jms/QueuecConFactory");
Initialcontext_props.put("queue.MyQueue" , queueName);
jndiContext = new InitialContext(Initialcontext_props);
it will work just fine . Also make sure u have addedd the active-mq's jar
file in ur classpath.
wallace wrote:
>
> I can make the jndi lookup working within jboss j2ee container. But jndi
> apparently does not work from a single standalone client, when accessing
> jndi of jboss.
>
> For example,
> Properties env2 = new Properties();
> ......
> env2.put(Context.INITIAL_CONTEXT_FACTORY,
> "org.jnp.interfaces.NamingContextFactory");
> env2.put(Context.PROVIDER_URL, "jnp://localhost:1099");
> InitialContext jndi2 = new InitialContext(env2);
>
> TopicConnectionFactory connectionFactory =
> (javax.jms.TopicConnectionFactory)
> jndi2.lookup("java:activemq/TopicConnectionFactory");
>
> The code always returns name not found exception. Has anyone ever made it
> work in standalone client?
>
> -Wallace Wong
>
>
>
> tbaker73 wrote:
>>
>> James, could you please provide an example of the connection factory
>> entry to add under <connection-factories> in a -ds.xml file that would
>> accomplish what you suggest? How would it differ from this entry?
>> <tx-connection-factory>
>> <jndi-name>activemq/QueueConnectionFactory</jndi-name>
>> <xa-transaction/>
>> <track-connection-by-tx/>
>> <rar-name>activemq-ra.rar</rar-name>
>>
>> <connection-definition>javax.jms.QueueConnectionFactory</connection-definition>
>> <ServerUrl>vm://localhost</ServerUrl>
>> <UserName>sa</UserName>
>> <Password></Password>
>> <min-pool-size>1</min-pool-size>
>> <max-pool-size>200</max-pool-size>
>> <blocking-timeout-millis>30000</blocking-timeout-millis>
>> <idle-timeout-minutes>3</idle-timeout-minutes>
>> </tx-connection-factory>
>>
>>
>> James.Strachan wrote:
>>>
>>>
>>> You'll need to setup a regular JMS connection and any destination
>>> objects you want in JNDI somewhere. Using JBoss's JNDI provider could
>>> well work fine though - just make sure its actually normal JMS client
>>> objects (ConnectionFactory & destinations) - and not RA stuff. Also
>>> make sure the J2EE server and your stand alone client are using the
>>> exact same ActiveMQ jars since its gonna be using Java serialization
>>> to transmit the Java objects in JNDI
>>> --
>>>
>>> James
>>> -------
>>> http://radio.weblogs.com/0112098/
>>>
>>>
>>
>>
>
>
--
View this message in context: http://www.nabble.com/JBoss-integration-and-lookup-of-connection-factories.-tf3061463s2354.html#a9918134
Sent from the ActiveMQ - User mailing list archive at Nabble.com.