All clients can lookup objects in the EMS naming service. Alternatively, Java applications can lookup objects in a third-party JNDI server, and C and C# clients can lookup objects in a third-party LDAP server. See Chapter 1, Using JNDI With Third-Party Naming/Directory Services in the TIBCO Enterprise Message Service Application Integration Guide for details on how to look up connection factories from a third-party JNDI or LDAP server.To lookup administered objects stored in EMS, you need to create the initial context that identifies the URL of the naming service provider and any other properties, such as the username and password to authenticate the client to the service. The naming service provider URL has form:The following examples demonstrate how to access JMS administered objects when using TIBCO Enterprise Message Service. Each of these examples assume that a connection factory, named ConFac, exists in the factories.conf file, a topic.sample topic exists in topics.conf, and a queue.sample queue exists in queues.conf.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: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:tibemsLookupContext* contextstatus = NULL;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:Topic sampleTopic = (javax.jms.Topic)jndiContext.lookup(
"tibjmsnaming://jmshost:7222/topic.sample");Queue sampleQueue = (javax.jms.Queue)jndiContext.lookup(
"tibjmsnaming://jmshost:7222/queue.sample");For further information on how to use full URL names, refer to the tibjmsJNDIRead.java example located in the EMS_HOME/samples/java/JNDI directory.TIBCO Enterprise Message Service client programs can perform secure JNDI lookups using the Secure Sockets Layer (SSL) protocol. To accomplish this, the client program must set SSL properties in the environment when the InitialContext is created. The SSL properties are similar to the SSL properties for the TIBCO Enterprise Message Service server. See Chapter 18, Using the SSL Protocol for more information about using SSL in the TIBCO Enterprise Message Service server.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.tibemsLookupContext* context = NULL;tibemsConnection_Factory factory = NULL;tibemsSSLParams sslParams = NULL;tibems_status status = TIBEMS_OK;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.TIBCO Enterprise Message Service can perform fault-tolerant JNDI lookups. If the primary server fails and the backup server becomes the primary, the JNDI provider automatically uses the new primary server for JNDI lookups. You accomplish this by providing multiple URLs in the Context.PROVIDER_URL property when creating the InitialContext. Specify more than one URL separated by commas (,) in the property.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 backup EMS server on the machine named backuphost.env.put(Context.PROVIDER_URL, "tibjmsnaming://jmshost:7222, tibjmsnaming://backuphost:7222");If at any time the first EMS server fails, the JNDI provider will automatically switch to the EMS server on the host backuphost for JNDI lookups. If emshost is repaired and restarted, it then becomes the backup EMS server.
• When looking up an object that has been bound into a foreign naming/directory service such as LDAP.
Copyright © TIBCO Software Inc. All Rights Reserved.