This is archived documentation for an older version of Nirvana (v2.0). Please refer to documentation for the latest version if required.

JMSAdmin

This example (jmsdmin.Java) demonstrates how to store Nirvana's JMS components into a JNDI service provider. The default service provider for the example uses Sun's file system provider however any JNDI contect provider can be used, from LDAP through to NIS.

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


Java -DRNAME [-DPRINCIPAL] [-DPASSWORD] -DCONTEXT_FACTORY -DPROVIDER_URL com.pcbsys.Nirvana.nSpace.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.sun.jndi.fscontext.RefFSContextFactory 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 the current working directory for the fscontext provider.

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 the following .bindings file in the current working directory:

#This file is used by the JNDI FSContext.
#Mon Jul 22 12:22:31 BST 2002
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 local machine. Assuming you wish to reference your local realm as a TopicConnectionFactory named vegetta in JMS use the following command:

Java com.pcbsys.Nirvana.nSpace.JMSAdmin bind topicFactory vegetta

The bindings file will now contain:

#This file is used by the JNDI FSContext.
#Mon Jul 22 12:27:24 BST 2002
vegetta/RefAddr/0/Type=TopicConnectionFactory
vegetta/FactoryName=com.pcbsys.Nirvana.nJMS.TopicConnectionFactoryFactory
rates/RefAddr/0/Type=Topic
vegetta/RefAddr/0/Encoding=String
rates/ClassName=javax.JMS.Topic
vegetta/ClassName=javax.JMS.TopicConnectionFactory
vegetta/RefAddr/0/Content=nsp\://127.0.0.1\:9000
rates/RefAddr/0/Encoding=String
rates/FactoryName=com.pcbsys.Nirvana.nJMS.TopicFactory
rates/RefAddr/0/Content=rates

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 can be bound into a name space using the following command

Java com.pcbsys.Nirvana.nSpace.JMSAdmin bind queueFactory qvegetta

Having run both queue related commands your local .bindings file will now contain the following:

#This file is used by the JNDI FSContext.
#Mon Jul 22 12:57:38 BST 2002
qvegetta/RefAddr/0/Encoding=String
vegetta/FactoryName=com.pcbsys.Nirvana.nJMS.TopicConnectionFactoryFactory
qvegetta/ClassName=javax.JMS.QueueConnectionFactory
rates/ClassName=javax.JMS.Topic
rates/RefAddr/0/Type=Topic
qvegetta/RefAddr/0/Type=QueueConnectionFactory
movie/RefAddr/0/Type=Queue
vegetta/RefAddr/0/Type=TopicConnectionFactory
movie/ClassName=javax.JMS.Queue
movie/RefAddr/0/Encoding=String
movie/RefAddr/0/Content=movie
vegetta/ClassName=javax.JMS.TopicConnectionFactory
rates/RefAddr/0/Encoding=String
vegetta/RefAddr/0/Encoding=String
qvegetta/FactoryName=com.pcbsys.Nirvana.nJMS.QueueConnectionFactoryFactory
movie/FactoryName=com.pcbsys.Nirvana.nJMS.QueueFactory
rates/RefAddr/0/Content=rates
qvegetta/RefAddr/0/Content=nsp\://127.0.0.1\:9000
rates/FactoryName=com.pcbsys.Nirvana.nJMS.TopicFactory
vegetta/RefAddr/0/Content=nsp\://127.0.0.1\:9000