Version 21

    WARNING: This is an example supplied by a user. Creating a durable subscription without specifying the client id is bad. TODO: Fix this example


    How to configure MDBs to subscribe to a topic in a cluster?


    Asynchronous messaging is useful for invalidation purpose across a cluster.



    Let's imagine a possible scenario composed of 2 nodes running in a cluster.



    • hajms runs the JMS server in HA-Singleton mode. This server hosts the topic.

    • node1 runs an MDB with durable subscription on the topic

    • the JMS client publishes messages to the topic


        node1             hajms
         MDB  <---------  topic
                        JMS client   


    Each node receives a copy of the message. This "notification" may then be use to trigger cached data invalidation or a configuration reload.



    Setup the environment





    Create a home directory. For now on we'll call it {wiki.dir}


    Download and unpack JBossAS 4.0.1SP1 in {wiki.dir}


    Get the attached package and explode it into {wiki.dir}


    Create three copies of the all server configuration as follows



       To make this demo more fun, we will bind each instance to a separate ip address. So first step is to configure those ips.


    Here is what I've got on my box

        hajms     -->  
        node1     -->







    Deploying the mdb


    On node1, the mdb makes a durable subscription anonymously to the topic bound in HA-JNDI as topic/testDurableTopic.





             <configuration-name>Standard Message Driven Bean</configuration-name>


      Let's deploy the mdb on both nodes


        cd to /hajms-clusteredtopic/src/build and type

        $ant deploy


        A deployment called MDB.jar is created and copied over to each node (/deploy directory)



    Starting the cluster


    Open 2 separate command line windows and start both node1 and hajms

       $sh -c hajms -b
       $sh -c node1 -b




    Running the client


    It's time to publish some messages to the topic




    Open another command line window and cd to /hajms-clusteredtopic/src/build  

     $ant run-failover



    On each instance, you should see the messages behing processed



       16:53:50,312 INFO  [DurableTopicBean] received message ID:7-11169464302961, payload: 0
       16:53:51,312 INFO  [DurableTopicBean] received message ID:7-11169464313122, payload: 1
       16:53:52,312 INFO  [DurableTopicBean] received message ID:7-11169464323123, payload: 2
       16:53:53,312 INFO  [DurableTopicBean] received message ID:7-11169464333124, payload: 3
       16:53:54,312 INFO  [DurableTopicBean] received message ID:7-11169464343125, payload: 4






    coming soon...







    1. This procedure can not be used as-is with JBossAS 4.0.2. Because of a bug in HA-JNDI auto-discovery, the client is not able to look up the topic.

       Until this issue is fixed, you should use the following JNDI properties

       #java.naming.provider.url=     <--- comment out this line and update it accordingly



    The second attached file hajms-clusteredtopic.tar.bz2 includes a SLSB with a method postMessage(int i).  This is included to demonstrate that you can post messages from within a cluster. The file also includes a SLSB client that can be run using ant

     $ant run-slsbclient


    The original jms client ant target has been changed from run-failover to

     $ant run-mdbclient


    This file also brings the MDB config up to J2EE 1.4.