High Quality Enterprise Messaging.

JNDI Replication into JBoss' JNDI

Introduction

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.

Configuration

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.

Example:

    <swiftlet name="sys$jndi">
      <aliases>
        <alias name="testqueue" map-to="testqueue@router1"/>
      </aliases>
      <jndi-replications>
        <jndi-replication name="jboss" destination-context="/swiftmq" enabled="true">
          <environment-properties>
            <environment-property name="java.naming.factory.initial"
                           value="org.jnp.interfaces.NamingContextFactory"/>
            <environment-property name="java.naming.provider.url"
                           value="localhost:1099"/>
          </environment-properties>
        </jndi-replication>
      <remote-queues>
        <remote-queue name="testqueue@router2"/>
      </remote-queues>
    </swiftlet>

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.

Example:

    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");