6 Replies Latest reply on Aug 22, 2003 3:09 PM by jcilke

    [proposal for a new component] lightweight clustered messagi

    ivelin.ivanov


      Since clustered JMS with load balancing will not be available until 4.0,
      I would like to propose a relatively low cost alternative for 3.x.


      Here is a use case and some sample code for the new component.

      register an MBean MessageBroadcaster.
      Pass partition name as one MBean attribute
      another MBean attribute DeliveryPolicy will control Pub/Sub vs P2P
      All MBeans with the same service name and partition name will connect to each other
      subscribers will call addListener(SomeListener)
      this will subscribe the listeners to the local broadcaster service
      notifiers will call notifyListeners() to the local (in VM) instance of the service
      the local instance will notify all local listeners as well as
      all other broadcasters in the partition, via RPC call
      each of the partition nodes will in turn call all their local listeners


      pseudo code:



      jboss:service=DefaultPartition
      DefaultPartition
      Broadcast | Point to Point





      class Toaster
      {
      addListener(ToasterListener tl)
      {
      }

      removeListener(tl) {...}

      startToasting()
      {
      ... do smth ...
      getEventDispatcher().toastingStarted( time );
      }

      endToasting() {... similarly ...}

      ToasterListener getEventDispatcher()
      {
      ClusteredEventDispatcher = jmxServer.findMBean( ... dispatcher mbean name ... );
      ClusteredEventDispatcher.getDispatcherProxy( ToasterListener.class );
      }

      }


      interface ToasterListener()
      {
      toastingStarted(long timestamp);
      toastingStopped(long timestamp);
      }


      class ClusteredEventDispatcher extends MBeanSupport
      {

      startService()
      {

      }

      // callback for remote rpc calls
      _dispatchEvent( Method methodToCall, args )
      {
      ... find proxy for the method's defining class
      ... call notifyLocalListeners on proxy
      }


      // there is only one proxy created per listener interface
      getDispatcher( Class someListener)
      {
      ... create new proxy for listener interface or return the old one if already created
      }

      class EventListenerProxy implements InvokationHandler
      {

      Object invoke(Object proxy, Method method, Object[] args)
      {
      List listeners = getLocaListeners(Method.getDeclaringClass());
      notifyLocalListeners(method, args);
      notifyRemoteListeners();
      }

      notifyLocalListeners(method, args)
      {
      ... iterate and call method reflectively ...
      }

      notifyRemoteListeners(method, args)
      {
      rpcCall("service:DefaultPartitionEventDispatcher", "_dispatchEvent", Method, args);
      }


      }


      } // end of EventDispatcherFactory





      Cheers,

      Ivelin

        • 1. Re: [proposal for a new component] lightweight clustered mes
          slaboure

          can you take a look at the jms code in CVS? there is a basic clustered thing already in there but I bet it is unsynch by now.

          What is your goal, specifically?

          The goal of the clustered JMS invoker was to say:
          - I store my messages in a shared DB or shared filesystem (let's say DB... first)
          - I have many JBoss nodes
          - the client lookup the jms client proxy that knows all nodes
          - if a node dies, it failovers to a new node, the node clear its message cache and connect to the db, etc.

          In short, it is like in commit option C (we dont' cache message) and we simply add a clustered JMS invoker.

          Would that better fit your needs?

          Cheers,


          sacha

          • 2. Re: [proposal for a new component] lightweight clustered mes
            ivelin.ivanov

            I would like to be able to subscribe once to a cluster wide message topic and not worry about which node is running the jms server.

            If I understand correctly, with the current implementation of JMS, I would have to dedicate one server as a master JMS server and subscribe to it from all other nodes to ensure that they all share the same message topics and queues.

            If it dies, I will have to worry about recreating its state (all topics and queues) on the next master.

            Unlike the HAJNDI, where I can bind an object once and it will be automatically replicated to all other nodes, with JMS, I cannot do same on all nodes: create a topic once and subscribe to it once, no matter which node publishes a new message, it will get to all the other ones. If a node fails, all the other ones will not have to worry about it.

            Does this clarify what I am looking for?

            • 3. Re: [proposal for a new component] lightweight clustered mes
              ivelin.ivanov

              In a direct email, Sacha gave me the green light to proceed with this component.

              This will be the behaviour of the service:

              - The service will provide a very lightweight and resource efficient way to reliably broadcast strongly typed messages in a cluster partition.
              - The service will send events asynchronously
              - The service will not make effort to ensure that the receivers are part of the sender's transaction or security context

              If the service gains popularity, we can add more requirements.

              • 4. Re: [proposal for a new component] lightweight clustered mes
                ivelin.ivanov
                • 5. Re: [proposal for a new component] lightweight clustered mes
                  ivelin.ivanov

                  completed work and checked-in code,examples and test under Branch_3_2. I can use some guidance when and how to check-in to HEAD.

                  Anyway, there is a an online article that describes the new service:

                  http://www.cocoonhive.org/articles/jboss/20030705/JBoss322-HAExamples.html

                  • 6. Re: [proposal for a new component] lightweight clustered mes

                    I'm trying to implement the HASingletonMBeanExample, but I receive an error "jboss:service=HASingletonMBeanExample is not registered." Any suggestions? I'm running JBoss-3.2.2RC2.

                    Second, I'm looking for an example of how to implement a JMS singleton, particularly the entires I need to add to cluster-examples-service.xml I want to run several JMS servers, but at any one time only one will server as the master.

                    -- John