Nirvana JMS - JMSAdmin

Nirvana's Enterprise Manager tool, provides full integrated support for JNDI using the same Nirvana Channel based context used by the JMSAdmin example. For more information on this, please click here.

The example (jmsdmin.Java) source code demonstrates how to store Nirvana's JMS components into a JNDI service provider. The default service provider for the example Nirvana's own Nirvana Context to store JMS objects references, however any JNDI contect provider can be used, from LDAP through to NIS. The Nirvana context is discussed in more detail here. The Nirvana Context stores references in a channel called /naming/defaultContext.

JMSAdmin creates all requried resources on a Nirvana realm. Example usage is as follows:

Java -DRNAME [-DPRINCIPAL] [-DPASSWORD] -DCONTEXT_FACTORY -DPROVIDER_URL JMSAdmin bind | unbind | list | queueFactory | topicFactory |connectionFactory | queue | topic name / alias

where :

RNAME is the realm name of the Nirvana server you wish to connect to. If no RNAME is provided the default RNAME of nsp://localhost:9000 is used.

PRINCIPAL is the subject ( if any) you 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 providers 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 Nirvana 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:

rates/RefAddr/0/Content=rates
rates/RefAddr/0/Type=Topic
rates/ClassName=javax.JMS.Topic
rates/FactoryName=com.pcbsys.Nirvana.nJMS.TopicFactory
rates/RefAddr/0/Encoding=String

The topic rates will automatically be created on the Nirvana 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/RefAddr/0/Type=TopicConnectionFactory
TopicConnectionFactory /FactoryName=com.pcbsys.Nirvana.nJMS.TopicConnectionFactoryFactory
TopicConnectionFactory/RefAddr/0/Encoding=String
TopicConnectionFactory/ClassName=javax.JMS.TopicConnectionFactory
TopicConnectionFactory/RefAddr/0/Content=nsp\://127.0.0.1\:9000
TopicConnectionFactory/RefAddr/0/Encoding=String

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, TopicConnectionFactory, QueueConnectionFactory, rates and movie. The NirvanaContext used with your JMS application will now be able to lookup these objects and use them within your application.