3 Replies Latest reply on Mar 3, 2005 6:22 PM by inders1

    Clustered Singleton Service and MDBs

      Hi:
      I am investigating the best apporach to make a service that listens for topic and queue messages (using MDBs) into a Clustered singleton service. Essentially I want the MDBs in an instance(node) of the service to setup listeners with JMS (SonicMQ server) only when that node becomes the master.

      Is there any preferred way of doing this? I looked through the documentation available online and forums, but couldnot fine any pointers.

      There are a few things that I was considering:
      1.) Have the onMessage() in the MDB check if it is running in the master instance before processing a message (this would only work for topic listeners).
      2.) Deploy the MDBs manually when a node becomes the master, if possible (is there an MBean that I can use to deploy/undeploy on the fly?)
      3.) Enhance JMSContainerInvoker for my specific requirements and make a ClusteredSingletonJMSContainerInvoker(whoa!!!). My specialized class will setup ConnectionConsumers only when it's node becomes the master.

      This is my first few days on JBoss clustering - any/all help is greatly appreciated.

      -Thanks in advance.
      -Inder.




        • 1. Re: Clustered Singleton Service and MDBs

          4) Put your mdb in deploy-hasingleton
          5) Create your own deploy-hasingleton-service.xml and use the mdb's url

          Number (3) is quite a good idea, but difficult to implement with the current
          HA Singleton, since you cannot do the following in java:

          SingletonJMSContainerInvoker extends JMSContainerInvoker, HASingletonSupport
          


          which is why "singleton" will be implemented as a microcontainer aspect in JBoss5

          • 2. Re: Clustered Singleton Service and MDBs

            Thanks Adrian.

            I will look into (4) and (5) to see if that helps me.

            Else, I believe I will have to find my way around to implement (3), by using an HASingletonSupport implementation that is a controller for SingletonJMSContainerInvoker.

            Will keep posted on which route I finally take.

            -Inder.

            • 3. Re: Clustered Singleton Service and MDBs

              I am trying to go with approach (4) - put my MDB in deploy-hasingleton, but it doesnot seem to work. (Note- when I put my MDBs in deploy or farm folder, it works just fine).

              Here is the exception I get on startup:

              15:13:46,546 WARN [EjbModule] Could not load the org.jboss.resource.connectionm
              anager.CachedConnectionInterceptor interceptor for this container
              javax.management.InstanceNotFoundException: jboss.jca:service=CachedConnectionManager is not registered....
              ...
              MBeans waiting for other MBeans:
              ObjectName: jboss.j2ee:binding=message-driven-bean,jndiName=local/DefaultProvide
              rMDB,plugin=invoker,service=EJB
              state: FAILED
              I Depend On:
              Depends On Me: javax.naming.NameNotFoundException: DefaultJMSProvider not bound


              MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM:
              ObjectName: jboss.j2ee:binding=message-driven-bean,jndiName=local/DefaultProvide
              rMDB,plugin=invoker,service=EJB
              state: FAILED
              I Depend On:
              Depends On Me: javax.naming.NameNotFoundException: DefaultJMSProvider not bound


              I am running in 'all' mode and have ensured that jmsjca-service.xml is in the deploy folder. Also, since I am using SonicMQ, and not JBossMQ, I have removed JBossMQ related configurations.

              My sonic-service.xml looks something like this:

              <?xml version="1.0" encoding="UTF-8"?>
              <server>
               <mbean code="com.integral.jmsx.jndi.jboss.JBossLoader" name="sonic.mq:service=JNDILoader">
               <attribute name="JNDIInitClassName">com.integral.jmsx.jndi.JmsJndiInit</attribute>
               <depends>jboss:service=Naming</depends>
               </mbean>
              
              
               <!-- The JMS provider loader -->
               <mbean code="org.jboss.jms.jndi.JMSProviderLoader"
               name="jboss.mq:service=JMSProviderLoader,name=JBossMQProvider">
               <attribute name="ProviderName">DefaultJMSProvider</attribute>
               <attribute name="ProviderAdapterClass">
               org.jboss.jms.jndi.JNDIProviderAdapter
               </attribute>
               <attribute name="QueueFactoryRef">java:/QueueConnectionFactory</attribute>
               <attribute name="TopicFactoryRef">java:/TopicConnectionFactory</attribute>
               </mbean>
              
               <!-- org.jboss.jms.jndi.JNDIProviderAdapter -->
               <!-- The server session pool for Message Driven Beans -->
               <mbean code="org.jboss.jms.asf.ServerSessionPoolLoader"
               name="jboss.mq:service=ServerSessionPoolMBean,name=StdJMSPool">
               <depends optional-attribute-name="XidFactory">jboss:service=XidFactory</depends>
               <attribute name="PoolName">StdJMSPool</attribute>
               <attribute name="PoolFactoryClass">
               org.jboss.jms.asf.StdServerSessionPoolFactory
               </attribute>
               </mbean>
              
               <!-- JMS XA Resource adapter, use this to get transacted JMS in beans -->
               <tx-connection-factory>
               <jndi-name>JmsXA</jndi-name>
               <xa-transaction/>
               <rar-name>jms-ra.rar</rar-name>
               <connection-definition>org.jboss.resource.adapter.jms.JmsConnectionFactory</connection-definition>
               <config-property name="SessionDefaultType" type="java.lang.String">javax.jms.Topic</config-property>
               <config-property name="JmsProviderAdapterJNDI" type="java.lang.String">java:/DefaultJMSProvider</config-property>
               <max-pool-size>20</max-pool-size>
               <security-domain-and-application>JmsXARealm</security-domain-and-application>
               </tx-connection-factory>
              </server>
              



              -Thanks.
              -Inder.