JNDI Replication into JBoss' JNDI


To use SwiftMQ's connection factories and destinations from MDBs/EJBs in JBoss, SwiftMQ's JNDI content needs to be replicated into JBoss' JNDI tree. Thereafter, MDBs/EJBs can use JBoss' JNP provider to look up SwiftMQ's administrative objects.


Put "jbossall-client.jar" and "jnp-client.jar" into the router's class path.

Create a new JNDI replication either with SwiftMQ Explorer/CLI or directly in the routerconfig.xml.


    <swiftlet name="sys$jndi">
        <alias name="testqueue" map-to="testqueue@router1"/>
        <jndi-replication name="jboss" destination-context="/swiftmq" enabled="true">
            <environment-property name="java.naming.factory.initial"
            <environment-property name="java.naming.provider.url"
        <remote-queue name="testqueue@router2"/>

Then start both, JBoss and SwiftMQ. During startup, SwiftMQ replicates its JNDI content into JBoss' JNDI tree below context "/swiftmq".

To ensure the foreign JNDI is up and running, a JNDI replication uses a keepalive mechanism to check that. On each keepalive interval, configured by the attribute "keepalive-interval", the replication component performs a JNDI lookup on the name, configured by the attribute "keepalive-lookup-name". It doesn't matter which name you specify here, since a NameNotFoundException is taken as ok; the foreign JNDI is up. All other exceptions are taken as the foreign JNDI is down. The replication component then tries to reconnect. Once a connection can be re-established, the whole JNDI content is replicated again.

It is recommended to enable the "jndi" trace space in the Trace Swiftlet during the configuration to see what's going on during the replication.

To lookup JNDI objects from a non-EJB/MDB JMS client, you have to put "jbossall-client.jar" and "jnp-client.jar" into the client's class path. Further, you need to change the client's JNDI properties.


    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
    env.put(Context.PROVIDER_URL, "localhost:1099");
    InitialContext ctx = new InitialContext(env);
    QueueConnectionFactory qcf = (QueueConnectionFactory) ctx.lookup("/swiftmq/plainsocket@router1");