Configuring JBoss JNDI to bind to JNDI on another server?

I have two JBoss servers, JbossA and JbossB. Everyone has their own JNDI. Now I have a JMS on JbossA named jms / Client and JMS on JbossB named jms / Server.

Now I want the JbossA application to be able to access jms / Server using native JNDI. I would also like the JbossB application to connect to jms / Client using jndi-name jms / Client1 using its own JNDI.

In short:

JbossA/
       JNDI/
            jms/Client
            jms/Server  -> JbossB/JNDI/jms/Server


JbossB/
       JNDI/
            jms/Server
            jms/Client1  -> JBossA/JNDI/jms/Client
  • AppA on JbossA accesses jms / Client and jms / Server using JbossA / JNDI
  • AppB on JbossB accesses jms / Server and jms / Client1 using JbossB / JNDI

Two questions:

  • Is it possible?
  • If so, how do I configure the setting in JBoss EAP 6.0.1 (Jboss 7.1)?
+3
source share
3 answers

-, , MDB, , ( JMS, ), JMS, , .

, JBoss 7 , Remote Naming Project , , , , -, EJB, . , JBoss ( ​​ ) ( , ?), JEE , Weblogic Foreign JNDI Binding, , , , , , .

API javax.naming , InitialContext.bind( String name, Object obj), javax.naming.Reference. javadocs, Reference javax.naming.RefAddr, info, javax.naming.spi.ObjectFactory, , . :

InitialContext ctx = new InitialContext();
ForeignJNDIObjectRefAddr refAddr = getRemoteObjectJNDIInfo(...;
ctx.bind("jms/Server", new Reference("java.lang.Object",
                refAddr, ForeignJNDIObjectFactory.class.getName(), null));

ForeignJNDIObjectRefAddr ForeignJNDIObjectFactory, , ForeignJNDIObjectFactory.getObjectInstance ForeignJNDIObjectRefAddr , . !

0

. , EAP. EAP, . .

EAP 6.2.0:

JNDI

​​ JBoss EAP 6 JBoss EAP 6 JNDI. ExternalContextMBean JBoss EAP 5.

EAP 6.0.x

<subsystem xmlns="urn:jboss:domain:naming:1.2">
    <bindings>
        <object-factory name="java:global/myExtContext" module="my.custom.module" class="my.example.class.ExternalContextObjectFactory"/>
    </bindings>
    <remote-naming/>
</subsystem>

ExternalContextObjectFactory my.custom.module,

public class ExternalContextObjectFactory implements ObjectFactory {
    @Override
    public Object getObjectInstance(final Object obj, final Name name, final Context nameCtx, final Hashtable<?, ?> environment) throws Exception {
      Hashtable env = new Hashtable();
      if(environment != null)
        env.putAll(environment);
      env.set( /* all the properties you will need for your target context */ );
      return new InitialContext(environment);
    }
} 

, java:global/myExtContext.

0

This is possible using the external JNDI federation included in EAP 6.x. You need to define global related properties. Rest for you to explore :)

Shishir

0
source

All Articles