Universal Messaging 10.1 | Developer Guide | Enterprise APIs | Enterprise Developer's Guide for Java | Provider for JMS | JMSAdmin: Sample application for creating realm resources
JMSAdmin: Sample application for creating realm resources
Universal Messaging's Enterprise Manager tool supports JNDI using the same Universal Messaging Channel based context used by the JMSAdmin example.
The example (jmsdmin.Java) source code demonstrates how to store Universal Messaging Provider for JMS components into a JNDI service provider. The default service provider for the example uses Universal Messaging's own Universal Messaging Context to store JMS objects references, however any JNDI context provider can be used, from LDAP through to NIS. The Universal Messaging context is discussed in more detail here. The Universal Messaging Context stores references in a channel called /naming/defaultContext.
JMSAdmin creates all required resources on a Universal Messaging realm. The command syntax is as follows:
Java com.pcbsys.nirvana.nSpace.JMSAdmin
-DPROVIDER_URL JMSAdmin bind | unbind | list | queueFactory |
topicFactory |connectionFactory | queue | topic name / alias
where the -D parameters have the following meaning:
*RNAME is the realm name of the Universal Messaging server you wish to connect to. If no RNAME is provided the default RNAME of nsp://localhost:9000 is used.
You can specify a cluster of realms by specifying a comma-separated list of connection URLs, for example "nsp://localhost:9000,nsp://localhost:9010".
If you want to use a round-robin connection factory, you can specify several connection URLs, where each connection URL can point to a standalone realm or a cluster. In this case, each connection URL is bounded by a set of round brackets - "(" and ")".
*(UM1)(UM2)(UM3)(UM4) - Indicates 4 standalone realms, namely UM1, UM2, UM3 and UM4, so 4 connections will be constructed here.
*(UM1,UM2)(UM3,UM4) - Indicates 2 clusters, one consisting of UM1 and UM2 and the other consisting of UM3 and UM4, so only 2 connections will be constructed here.
*(UM1)(UM2,UM3)(UM4) - Indicates one cluster consisting of UM2 and UM3, and two standalone realms, namely UM1 and UM4. A total of 3 connections will be constructed here
For the round-robin URL syntax, the following rules apply:
*Each set of brackets must contain at least one valid connection URL.
*There is no limit on the number of sets of brackets in the URL.
*Each set of bracket indicates a unique connection, and the realm names within each sets of brackets will be supplied unchanged to the underlying implementation.
*PRINCIPAL is the subject (if any) that your JNDI service provider requires.
*PASSWORD is the PRINCIPAL's password for the JNDI service provider used.
*CONTEXT_FACTORY is the fully qualified class name of the provider's context factory implementation. The default CONTEXT FACTORY is com.pcbsys.nirvana.nSpace.NirvanaContextFactory and is set automatically if no CONTEXT_FACTORY parameter is provided.
*PROVIDER_URL is the custom URL required by the context factory and provider implementation. If no PROVIDER_URL parameter is passed, the default used is nsp://localhost:9000/.
As an example, assume we want to create a TOPIC called rates on a Universal Messaging realm running on our local machine. Typing:
Java com.pcbsys.nirvana.nSpace.JMSAdmin bind topic rates
Will create an event in the /naming/defaultContext channel with the following information in the event properties of the event:
The topic rates will automatically be created on the Universal Messaging realm running on the PROVIDER_URL value. Assuming you wish to reference your local realm as a TopicConnectionFactory named TopicConnectionFactory in JMS, use the following command:
Java com.pcbsys.nirvana.nSpace.JMSAdmin bind topicFactory TopicConnectionFactory
This will publish an event to the /naming/defaultContext channel with the following information in the event dictionary:
TopicConnectionFactory /FactoryName=com.pcbsys.nirvana.nJMS.TopicConnectionFactoryFactory
Creating a queue can be achieved using the following command:
Java com.pcbsys.nirvana.nSpace.JMSAdmin bind queue movie
Likewise, a JMS queue connection factory called QueueConnectionFactory can be bound into a name space using the following command
Java com.pcbsys.nirvana.nSpace.JMSAdmin bind queueFactory QueueConnectionFactory
Having run both queue related commands, the /naming/defaultContext channel will contain 4 events, each one pertaining to the 4 objects that have been bound, namely TopicConnectionFactory, QueueConnectionFactory, rates and movie. The Universal Messaging Context used with your JMS application will now be able to look up these objects and use them within your application.