You can connect to any JMS server by using the Java Naming and Directory Interface (JNDI) to locate an existing JMS connection factory.
Depending on where the connection factory is bound, the connection URL can begin with the string lookup or the string jndi.
The appropriate JNDI provider jar files must be in the runtime classpath. With the GlassFish application server, you copy these jar files to the lib directory. In addition, JMS provider client jar files are needed in the runtime classpath.
To access a connection factory that is bound in the JNDI space of the GlassFish application server itself, use the lookup approach.
This scenario can occur when a managed connection factory has been created. Managed connection factories provide additional services on top of a connection factory. The additional services include connection pooling. The managed connection factory creates a connection factory wrapper.
Set the connection URL to lookup://JNDI-name, where JNDI-name is the JNDI name to which the connection factory is bound. For example:
lookup://jms/tx/default |
When you use a wizard to create a JMS-based concrete WSDL document, you set the connection URL in the Request Connection Configuration step of the wizard. For more information, see Creating JMS-Based Concrete WSDL Documents.
When you finish the wizard, the appropriate WSDL code is generated. The connection URL appears in the address element. For example:
<port name="newWSDL_InPort" binding="tns:JMSInBinding"> <jms:address connectionURL="lookup://jms/tx/default"> <jms:jmsjcaOptions><![CDATA[]]></jms:jmsjcaOptions> </jms:address> </port> |
At runtime, the JMS Binding Component uses the JNDI name to obtain the connection factory.
Use the jndi approach for either of the following scenarios:
To look up a connection factory in an external JNDI provider (for example, file or LDAP).
To look up a connection factory in a JNDI provider in the JMS server itself.
Set the connection URL to jndi:// and specify the JNDI options.
When you use a wizard to create a JMS-based concrete WSDL document, you set the connection URL in the Request Connection Configuration step of the wizard. You then specify the JNDI options in the Advanced Configuration step of the wizard. For more information, see Creating JMS-Based Concrete WSDL Documents.
The following table describes the available JNDI options.
The destinationType and transaction attributes in the WSDL document determine what type of connection factory is being looked up. For example, if the destinationType attribute is Queue and the transaction attribute is XATransaction, then the connection factory must be of type javax.jms.XAQueueConnectionFactory.
The following code shows an example of specifying the JNDI options. In this scenario, the connection factory is bound in the JMS server itself.
JMSJCA.UnifiedCF=connectionfactories/xaconnectionfactory JMSJCA.TopicCF=connectionfactories/xatopicconnectionfactory JMSJCA.QueueCF=connectionfactories/xaqueueconnectionfactory java.naming.factory.initial=com.stc.jms.jndispi.InitialContextFactory java.naming.provider.url=stcms://localhost:18007 java.naming.security.principal=Administrator java.naming.security.credentials=STC |
When you finish the wizard, the appropriate WSDL code is generated. The connection URL appears in the address element. The JNDI options appear in the jmsjcaOptions element. For example:
<port name="newWSDL_InPort" binding="tns:JMSInBinding"> <jms:address connectionURL="jndi://"> <jms:jmsjcaOptions> <![CDATA[JMSJCA.UnifiedCF=connectionfactories/xaconnectionfactory JMSJCA.TopicCF=connectionfactories/xatopicconnectionfactory JMSJCA.QueueCF=connectionfactories/xaqueueconnectionfactory java.naming.factory.initial=com.stc.jms.jndispi.InitialContextFactory java.naming.provider.url=stcms://localhost:18007 java.naming.security.principal=Administrator java.naming.security.credentials=STC]]> </jms:jmsjcaOptions> </jms:address> </port> |
At runtime, the JMS Binding Component uses the JNDI options to obtain the connection factory.