Repository: qpid-jms Updated Branches: refs/heads/master ee314669b -> 8230546df
add initial details around configuring the client JNDI context Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/8230546d Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/8230546d Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/8230546d Branch: refs/heads/master Commit: 8230546df83b4915da4a8520bc6de78cd9625bd1 Parents: ee31466 Author: Robert Gemmell <[email protected]> Authored: Thu Feb 5 17:27:42 2015 +0000 Committer: Robert Gemmell <[email protected]> Committed: Thu Feb 5 17:28:05 2015 +0000 ---------------------------------------------------------------------- Configuration.md | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/8230546d/Configuration.md ---------------------------------------------------------------------- diff --git a/Configuration.md b/Configuration.md index 27a7b45..bee8805 100644 --- a/Configuration.md +++ b/Configuration.md @@ -1,6 +1,52 @@ # Client configuration -The client can be configured with a number of different settings using the connection URI. +This file details various configuration options for the client, such as how to configure and create a JNDI InitialContext, the sytax for its related property values, and various URI options that can be set when configuring a ConnectionFactory. + +## Configuring a JNDI InitialContext + +Applications use a JNDI InitialContext, itself obtained from an InitialContextFactory, to look up JMS objects such as ConnectionFactory. The Qpid JMS client provides an implementation of the InitialContextFactory in class *org.apache.qpid.jms.jndi.JmsInitialContextFactory*. This may be configured and used in three main ways: + +1. Via jndi.properties file on the Java Classpath. + +By including a file named jndi.properties on the Classpath and setting the *java.naming.factory.initial* property to value *org.apache.qpid.jms.jndi.JmsInitialContextFactory*, the Qpid InitialContextFactory implementation will be discovered when instantiating InitialContext object. + + javax.naming.Context ctx = new javax.naming.InitialContext(); + +The particular ConnectionFactory, Queue and Topic objects you wish the context to contain are configured using properties (the syntax for which is detailed in the next section) either directly within the jndi.properties file, or in a separate file which is referenced in jndi.properties using the *java.naming.provider.url* property. + +2. Via system properties. + +By setting the *java.naming.factory.initial* system property to value *org.apache.qpid.jms.jndi.JmsInitialContextFactory*, the Qpid InitialContextFactory implementation will be discovered when instantiating InitialContext object. + + javax.naming.Context ctx = new javax.naming.InitialContext(); + +The particular ConnectionFactory, Queue and Topic objects you wish the context to contain are configured as properties in a file, which is passed using the *java.naming.provider.url* system property. The syntax for these properties is detailed in the next section. + +3. Programatically using an environment Hashtable. + + Hashtable<Object, Object> env = new Hashtable<Object, Object>(); + env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.qpid.jms.jndi.JmsInitialContextFactory"); + javax.naming.Context context = new javax.naming.InitialContext(env); + +The particular ConnectionFactory, Queue and Topic objects you wish the context to contain are configured as properties (the syntax for which is detailed in the next section), either directly within the environment Hashtable, or in a separate file which is referenced using the *java.naming.provider.url* property within the environment Hashtable. + +## Qpid JmsInitialContextFactory properties syntax + +* To define a ConnectionFactory: connectionfactory.lookupName = URI + connectionfactory.myFactoryLookup = amqp://localhost:5672 +* To define a Queue: queue.lookupName = queueName + queue.myQueueLookup = queueA +* To define a Topic: topic.lookupName = topicName + topic.myTopicLookup = topicA + +These objects could then be looked up from a Context as follows: + ConnectionFactory factory = (ConnectionFactory) context.lookup("myFactoryLookup"); + Destination queue = (Destination) context.lookup("myQueueLookup"); + Destination topic = (Destination) context.lookup("myTopicLookup"); + +# Connection URI options + +The client can be configured with a number of different settings using the connection URI while defining the ConnectionFactory. ## JMS Configuration options --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
