You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by "Alex Rudyy (JIRA)" <ji...@apache.org> on 2015/05/25 16:55:17 UTC

[jira] [Comment Edited] (QPID-6556) Document how to bind JMS client destinations and connection factories into Tomcat JNDI

    [ https://issues.apache.org/jira/browse/QPID-6556?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14558305#comment-14558305 ] 

Alex Rudyy edited comment on QPID-6556 at 5/25/15 2:54 PM:
-----------------------------------------------------------

Qpid Client destinations and connection factories can be registered in external JNDI containers, for example Tomcat JNDI implementation.
AMQConnectionFactory implements "javax.naming.spi.ObjectFactory" interface allowing to instantiate instances of  AMQConnectionFactory , AMQConnection, AMQQueue and AMQTopic in external JNID container from  javax.naming.References. Additionally, AMQConnectionFactory and AMQDestination (parent of AMQQueue and AMQTopic) implement javax.naming.Referenceable interface allowing creation of javax.naming.Reference to itself for binding in external JNDI implementations.

AMQConnectionFactory allows to create:
* an instance of ConnectionFactory from a References containing reference address (RefAddr) of type "org.apache.qpid.client.AMQConnectionFactory" with a content set to Connection URL
* an instance of Connection from a References containing reference address (RefAddr) of type "org.apache.qpid.client.AMQConnection" with a content set to Connection URL
* an instance of of AMQQueue from a References containing reference address (RefAddr) of type "org.apache.qpid.client.AMQQueue" with a content set to a destination Binding URL
* an instance of of AMQTopic from a References containing reference address (RefAddr) of type "org.apache.qpid.client.AMQTopic" with a content set to a destination Binding URL

An example below demonstrates how to create JNDI resources in Tomcat container using Resource declartion in context.xml(usually added into war under /META-INF/context.xml ).
{code:xml}
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE xml>
<Context>

  <Resource name="jms/connectionFactory" auth="Container"
            type="org.apache.qpid.client.AMQConnectionFactory"
            factory="org.apache.qpid.client.AMQConnectionFactory"
            org.apache.qpid.client.AMQConnectionFactory="amqp://guest:guest@clientid/?brokerlist='localhost:5672'"/>

  <Resource name="jms/queue" auth="Container"
              type="org.apache.qpid.client.AMQQueue"
              factory="org.apache.qpid.client.AMQConnectionFactory"
              org.apache.qpid.client.AMQQueue="direct://amq.direct//myDurableQueue?durable='true'"/>

  <Resource name="jms/topic" auth="Container"
              type="org.apache.qpid.client.AMQTopic"
              factory="org.apache.qpid.client.AMQConnectionFactory"
              org.apache.qpid.client.AMQTopic="topic://amq.topic?routingkey='myTopic'"/>

</Context>
{code}

In the example above ConnectionFactory would be registered under JNDI name "jms/connectionFactory", queue "myDurableQueue" would be resitered under JNDI name "jms/queue" and JMS topic destination "myTopic" would be registered under JNDI name "jms/topic". (All resources will be bound under "java:comp/env").

The client application can find the resources declared in Tomcat context.xml using the code below:
{code}
Context context = new InitialContext();
Context environmentContext = (Context)context.lookup("java:comp/env");
...
ConnectionFactory connectionFactory = (ConnectionFactory) environmentContext .lookup("jms/connectionFactory");
...
Queue queue = (Queue)environmentContext .lookup("jms/queue");
...
Topic topic = (Topic)environmentContext .lookup("jms/topic");
...
{code}

{panel}
Note that AMQDestination (parent of AMQQueue and AMQTopic) implements Externalizable allowing to serialize Address based and BURL based destinations. At the moment only BURL-based destinations can be registered in external JNDI container.
{panel}



was (Author: alex.rufous):
Qpid Client destinations and connection factories can be registered in external JNDI containers, for example Tomcat JNDI implementation.
AMQConnectionFactory implements "javax.naming.spi.ObjectFactory" interface allowing to instantiate instances of  AMQConnectionFactory , AMQConnection, AMQQueue and AMQTopic in external JNID container from  javax.naming.References. Additionally, AMQConnectionFactory and AMQDestination (parent of AMQQueue and AMQTopic) implement javax.naming.Referenceable interface allowing creation of javax.naming.Reference to itself for binding in external JNDI implementations.

AMQConnectionFactory allows to create:
* an instance of ConnectionFactory from a References containing reference address (RefAddr) of type "org.apache.qpid.client.AMQConnectionFactory" with a content set to Connection URL
* an instance of Connection from a References containing reference address (RefAddr) of type "org.apache.qpid.client.AMQConnection" with a content set to Connection URL
* an instance of of AMQQueue from a References containing reference address (RefAddr) of type "org.apache.qpid.client.AMQQueue" with a content set to a destination Binding URL
* an instance of of AMQTopic from a References containing reference address (RefAddr) of type "org.apache.qpid.client.AMQTopic" with a content set to a destination Binding URL

An example below demonstrates how to create JNDI resources in Tomcat container using Resource declartion in context.xml(usually added into war under /META-INF/context.xml ).
{code:xml}
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE xml>
<Context>

  <Resource name="jms/connectionFactory" auth="Container"
            type="org.apache.qpid.client.AMQConnectionFactory"
            factory="org.apache.qpid.client.AMQConnectionFactory"
            org.apache.qpid.client.AMQConnectionFactory="amqp://guest:guest@clientid/?brokerlist='localhost:5672'"/>

  <Resource name="jms/queue" auth="Container"
              type="org.apache.qpid.client.AMQQueue"
              factory="org.apache.qpid.client.AMQConnectionFactory"
              org.apache.qpid.client.AMQQueue="direct://amq.direct//myDurableQueue?durable='true'"/>

  <Resource name="jms/topic" auth="Container"
              type="org.apache.qpid.client.AMQTopic"
              factory="org.apache.qpid.client.AMQConnectionFactory"
              org.apache.qpid.client.AMQTopic="topic://amq.topic?routingkey='myTopic'"/>

</Context>
{code}

In the example above ConnectionFactory would be registered under JNDI name "jms/connectionFactory", queue "myDurableQueue" would be resitered under JNDI name "jms/queue" and JMS topic destination "myTopic" would be registered under JNDI name "jms/topic". (All resources will be bound under "java:comp/env").

The client application can find the resources declared in Tomcat context.xml using the code below:
{code}
Context context = new InitialContext();
Context environmentContext = (Context)context.lookup("java:comp/env");
...
ConnectionFactory connectionFactory = (ConnectionFactory) environmentContext .lookup("jms/connectionFactory");
...
Queue queue = (Queue)environmentContext .lookup("jms/queue");
...
Topic topic = (Topic)environmentContext .lookup("jms/topic");
...
{code}

{note}
Note that AMQDestination (parent of AMQQueue and AMQTopic) implements Externalizable allowing to serialize Address based and BURL based destinations. At the moment only BURL-based destinations can be registered in external JNDI container.
{note}


> Document how to bind JMS client destinations and connection factories into Tomcat JNDI 
> ---------------------------------------------------------------------------------------
>
>                 Key: QPID-6556
>                 URL: https://issues.apache.org/jira/browse/QPID-6556
>             Project: Qpid
>          Issue Type: Task
>          Components: Documentation
>            Reporter: Alex Rudyy
>            Assignee: Alex Rudyy
>             Fix For: 6.0 [Java]
>
>
> Qpid JMS client AMQConnectionFactory implements javax.naming.spi.ObjectFactory allowing a creation of connection factory instances and destination instances in external JNDI container.
> There is no documentation at the moment about how to integrate Qpid JMS client into JNDI containers. The aim of this JIRA is to add an section into Qpid JMS client documentation about how to integrate  Qpid JMS client into Tomcat Web container JNDI.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org