-
1. Re: JNDI lookup from JBoss embedded MQ Provider
moonbird79 Aug 25, 2009 6:26 PM (in response to moonbird79)This is my code fragment, after the jndi lookup conectionfactory and the destination are both null :-( :
// initialize jndi connection (jboss specific configuration) Properties props = new Properties(); props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); props.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming.client"); props.setProperty(Context.PROVIDER_URL, "jnp://localhost:1099"); //props.setProperty("j2ee.clientName", "TestClient"); // this is from http://activemq.apache.org/jndi-support.html //props.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.apache.activemq.jndi.ActiveMQInitialContextFactory"); //props.setProperty(Context.PROVIDER_URL,"tcp://localhost:61616"); // declare all variables for jndi and message transfer needed Context ctx = null; ActiveMQConnectionFactory queueConnectionFactory = null; QueueConnection queueConnection = null; QueueSession queueSession = null; Queue stationInfoQueue = null; MessageProducer msgProducer = null; TextMessage textMessage = null; // create new initial context from jndi try { ctx = new InitialContext(props); } catch (NamingException e) { System.out.println("Could not create JNDI API context: " + e); System.exit(1); } // Look up connection factory and destination try { ConnectionFactory factory = (ConnectionFactory) ctx.lookup("activemq/QueueConnectionFactory"); //queueConnectionFactory = new ActiveMQConnectionFactory(ActiveMQConnection.DEFAULT_BROKER_URL); stationInfoQueue = (Queue) ctx.lookup("stationInfoQueue"); if (factory == null) { System.out.println("NULL for queueConnectionFactory"); } if (stationInfoQueue == null) { System.out.println("NULL for stationInfoQueue"); } } catch (NamingException e) { System.out.println("JNDI API lookup failed:" + e); System.exit(1); }
-
2. Re: JNDI lookup from JBoss embedded MQ Provider
moonbird79 Aug 26, 2009 6:48 AM (in response to moonbird79)This is my datasource for the activemq provider:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE connection-factories PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN" "http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd"> <connection-factories> <tx-connection-factory> <jndi-name>activemq/QueueConnectionFactory</jndi-name> <xa-transaction/> <use-java-context>false</use-java-context> <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> <tx-connection-factory> <jndi-name>activemq/TopicConnectionFactory</jndi-name> <xa-transaction/> <track-connection-by-tx/> <rar-name>activemq-ra.rar</rar-name> <connection-definition>javax.jms.TopicConnectionFactory</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> <mbean code="org.jboss.resource.deployment.AdminObject" name="activemq.queue:name=outboundQueue"> <attribute name="JNDIName">stationInfoQueue</attribute> <depends optional-attribute-name="RARName">jboss.jca:service=RARDeployment,name='activemq-ra.rar'</depends> <attribute name="Type">javax.jms.Queue</attribute> <attribute name="Properties">PhysicalName=queue.outbound</attribute> </mbean> <mbean code="org.jboss.resource.deployment.AdminObject" name="activemq.topic:name=inboundTopic"> <attribute name="JNDIName">activemq/topic/inbound</attribute> <depends optional-attribute-name="RARName">jboss.jca:service=RARDeployment,name='activemq-ra.rar'</depends> <attribute name="Type">javax.jms.Topic</attribute> <attribute name="Properties">PhysicalName=topic.inbound</attribute> </mbean> </connection-factories>
and this is the result of my GLOBAL JNDI Namespace (JBoss Console):
+- activemq (class: org.jnp.interfaces.NamingContext)
| +- topic (class: org.jnp.interfaces.NamingContext)
| | +- inbound (class: org.apache.activemq.command.ActiveMQTopic)
| +- QueueConnectionFactory (class: org.apache.activemq.ra.ActiveMQConnectionFactory)
+- stationInfoQueue (class: org.apache.activemq.command.ActiveMQQueue)
+- ConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory) -
3. Re: JNDI lookup from JBoss embedded MQ Provider
moonbird79 Aug 26, 2009 6:50 AM (in response to moonbird79)... and as far as this site describes:
http://activemq.apache.org/jndi-support.html
"ActiveMQ will work with any JNDI provider capable of storing Java objects." -
4. Re: JNDI lookup from JBoss embedded MQ Provider
moonbird79 Aug 26, 2009 6:52 AM (in response to moonbird79)and - if i uncomment:
//queueConnectionFactory = new ActiveMQConnectionFactory(ActiveMQConnection.DEFAULT_BROKER_URL);
it works - but - without jndi support :-( and ActiveMQConnectionFactory is not a JMS API call ! :-( -
5. Re: JNDI lookup from JBoss embedded MQ Provider
moonbird79 Aug 26, 2009 7:10 AM (in response to moonbird79)for alle people who dont know why my connectionfactory is available in the (not common for jca ressource adapter) GLOBAL jndi namespace, you have to use:
<use-java-context>false</use-java-context>
... in your datasource file. ;-) -
6. Re: JNDI lookup from JBoss embedded MQ Provider
vickyk Aug 27, 2009 12:26 AM (in response to moonbird79)"moonbird79" wrote:
+- activemq (class: org.jnp.interfaces.NamingContext)
| +- topic (class: org.jnp.interfaces.NamingContext)
| | +- inbound (class: org.apache.activemq.command.ActiveMQTopic)
| +- QueueConnectionFactory (class: org.apache.activemq.ra.ActiveMQConnectionFactory)
+- stationInfoQueue (class: org.apache.activemq.command.ActiveMQQueue)
+- ConnectionFactory (class: org.jboss.jms.client.JBossConnectionFactory)
The following call should workConnectionFactory factory = (ConnectionFactory) ctx.lookup("activemq/QueueConnectionFactory");
What error do you get when this is called?
Does this configuration work in JBoss4.x series? -
7. Re: JNDI lookup from JBoss embedded MQ Provider
moonbird79 Aug 27, 2009 7:21 AM (in response to moonbird79)...this is what i tryed :-/ the lookup call throw no exceptions but the queueConnectionFactory object is null (i got the output NULL for queueC...).
STRANGE :-(
if i try to create a new queueConnection like this:
queueConnection = queueConnectionFactory.createQueueConnection();
... of course - i get a null pointer exception :-/
... i use JBoss 5.1 GA -
8. Re: JNDI lookup from JBoss embedded MQ Provider
moonbird79 Aug 27, 2009 7:57 AM (in response to moonbird79)Is this topic a JBoss JNDI bug ?
http://www.nabble.com/JNDI-with-ActiveMQ-embedded-in-JBoss-AS-td25151104.html