Chakradhar K
Chakradhar K

Reputation: 509

How to lookup remote JNDI

Is it possible to lookup remote JNDI in IBM MQ. My scenario is I have an MQ installation on machine A, with JNDI resources(JMS Administered objects in MQ Explorer).Now if I want to connect to MQ via JMS from standalone JAVA class, I can lookup from "file://JNDI_FACTORY". All examples only mention this. But is it possible if I want that standalone JAVA class on machine B. That is machine B has JAVA Class which has to connect to remote JNDI(on machine A) and look up for Connection Factory. Can I use some thing like "hostname of A:port" for property ContextProviderUrl in java class in machine B, to access remote objects from machine A?

Also suggest me on remote JNDI lookup.

Please help!

THANKS CHAKRI

Upvotes: 2

Views: 9473

Answers (1)

Shashi
Shashi

Reputation: 15263

For simplicity all MQ JMS samples use a File JNDI to demonstrate usage of initial context. You can modify the samples to look up a LDAP server for connection factory and destination information.

First in MQExplorer you need to choose LDAP Server option to save the connection factory and destination information to a LDAP server. Then in your application you need to have code that looks like this:

  String initialContextUrl = "ldap://myhost:991/c=uk,o=ACME"
  String contextFactory = "com.sun.jndi.ldap.LdapCtxFactory";
  Hashtable environment = new Hashtable();
  environment.put(Context.INITIAL_CONTEXT_FACTORY, contextFactory);
  environment.put(Context.PROVIDER_URL, initialContextUrl);
  Context context = new InitialDirContext(environment);

Please see the Infocenter topic Using JNDI to retrieve administered objects in a JMS application for details and additional code samples.

Upvotes: 4

Related Questions