Create an InitialContext object for the initial context, which consists of the provider context factory and JNDI provider URL, as well as the username and password to authenticate the client to the EMS server:
Look up a connection factory, named ConFac, and destinations, named
topic.sample and
queue.sample, from the initial context:
See the tibjmsJNDI.java sample client located in the
EMS_HOME/samples/java/JNDI directory.
Create a tibemsLookupContext object for the initial context, which consists of the JNDI provider URL and the username and password to authenticate the client to the EMS server:
Use the tibemsLookupContext_LookupConnectionFactory function to look up a connection factory, named
ConFac, and use the
tibemsLookupContext_LookupDestination function to look up the destinations, named
topic.sample and
queue.sample, from the initial context:
Create a ILookupContext object for the initial context, which consists of the JNDI provider URL and the username and password to authenticate the client to the EMS server:
Use the ILookupContext.Lookup method to look up a connection factory, named
ConFac, and destinations, named
topic.sample and
queue.sample, from the initial context:
Java clients can look up administered objects using full URL names. In this case, the Context.URL_PKG_PREFIXES property is used in place of the
Context.PROVIDER_URL property. For example:
The following examples illustrate how to create an InitialContext that can be used to perform JNDI lookups using the SSL protocol.
In this example, the port number specified for the Context.PROVIDER_URL is set to the SSL listen port that was specified in the server configuration file
tibjsmd.conf. The value for
TibjmsContext.SECURITY_PROTOCOL is set to
ssl. Finally, the value of
TibjmsContext.SSL_ENABLE_VERIFY_HOST is set to
"false" to turn off server authentication. Because of this, no trusted certificates need to be provided and the client will then not verify the server it is using for the JNDI lookup against the server’s certificate.
Create a tibemsSSLParams object and use the
tibemsSSLParams_SetIdentityFile function to establish the client identity by means of a
pkcs12 file. Use the
tibemsLookupContext_CreateSSL function to create a
tibemsLookupContext object that uses an SSL connection for the initial context.
Create a ILookupContext object for the initial context over an SSL connection. The SSL Store Info consists of a pkcs12 file that identifies the client and the client’s password, which are stored in an
EMSSSLFileStoreInfo object.
The following illustrates setting up the Context.PROVIDER_URL property with the URLs of a primary EMS server on the machine named
emshost and a secondary EMS server on the machine named
backuphost.
Assuming emshost starts out as active, if at any time it fails the JNDI provider automatically switches to the EMS server on the host
backuphost for JNDI lookups. If
emshost is repaired and restarted, it then becomes the standby EMS server.