7 Replies Latest reply on Feb 22, 2007 7:42 AM by lgsw_sam

    Singleton MDB

    lgsw_sam

      Hi!
      We are using JBoss 4.0.5 GA - ejb3, Hibernate 3.2.

      Is there a way to implement singleton MDB with ejb3?

      We tried

      @ActivationConfigProperty(propertyName = "maxSession", propertyValue = "1")
      


      but it did not work...

      We have two problems at the moment of which one is that our program tries to connect database with connection already being used. We believe that this is related to there being more than one MDB.

      Another problem is that we get too many connections to database.

      We get these Exceptions while connecting...

      2007-01-23 13:57:58,817 DEBUG [fi.logiasoftware.jca.adapter.GenericManagedConnection] GenericManagedConnection destroy()
      2007-01-23 13:57:58,817 DEBUG [fi.logiasoftware.jca.adapter.GenericManagedConnection] handler fi.logiasoftware.jca.handlers.FTPProtocolHandler@2c902c
      90 for fi.logiasoftware.jca.adapter.GenericManagedConnection@5d2c5d2c
      2007-01-23 13:57:58,817 DEBUG [fi.logiasoftware.jca.handlers.FTPProtocolHandler] FTPProtocolHandler boolean isConnected()
      2007-01-23 13:58:08,971 WARN [fi.logiasoftware.jca.handlers.FTPProtocolHandler] 49 IOException in connect() : Read timed out
      2007-01-23 13:58:08,972 WARN [fi.logiasoftware.jca.handlers.FTPProtocolHandler] 49Could not connect to 192.194.71.123:21.
      2007-01-23 13:58:08,972 WARN [org.jboss.resource.connectionmanager.JBossManagedConnectionPool] Unable to fill pool
      javax.resource.ResourceException: fi.logiasoftware.jca.common.ProtocolHandlerException: 49Could not connect to 192.194.71.123:21.
       at fi.logiasoftware.jca.adapter.GenericManagedConnectionFactory.createManagedConnection(GenericManagedConnectionFactory.java:137)
       at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.createConnectionEventListener(InternalManagedConnectionPool.java:565)
       at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.fillToMin(InternalManagedConnectionPool.java:512)
       at org.jboss.resource.connectionmanager.PoolFiller.run(PoolFiller.java:74)
       at java.lang.Thread.run(Thread.java:797)
      Caused by:
      fi.logiasoftware.jca.common.ProtocolHandlerException: 49Could not connect to 192.194.71.123:21.
       at fi.logiasoftware.jca.handlers.FTPProtocolHandler.connect(FTPProtocolHandler.java:119)
       at fi.logiasoftware.jca.adapter.GenericManagedConnectionFactory.createManagedConnection(GenericManagedConnectionFactory.java:126)
       ... 4 more
      2007-01-23 13:58:08,978 DEBUG [fi.logiasoftware.jca.adapter.GenericManagedConnectionFactory] GenericManagedConnectionFactory createManagedConnection(
      Subject subject, ConnectionRequestInfo o)
      2007-01-23 13:58:08,978 DEBUG [fi.logiasoftware.jca.adapter.GenericManagedConnection] GenericManagedConnection GenericManagedConnection(ManagedConnec
      tionFactory)
      2007-01-23 13:58:08,979 DEBUG [fi.logiasoftware.jca.adapter.GenericManagedConnection] GenericManagedConnection setConnection(AbstractProtocolHandler
      handler)
      2007-01-23 13:58:08,979 DEBUG [fi.logiasoftware.jca.adapter.GenericManagedConnection] GenericManagedConnection addConnectionEventListener(ConnectionE
      ventListener arg0)
      2007-01-23 13:58:08,979 TRACE [org.jboss.resource.connectionmanager.JBossManagedConnectionPool] Filling pool cl=org.jboss.resource.connectionmanager.
      NoTxConnectionManager$NoTxConnectionEventListener@46e046e[state=NORMAL mc=fi.logiasoftware.jca.adapter.GenericManagedConnection@4640464 handles=0 las
      tUse=1169553488979 permit=false trackByTx=false mcp=null context=org.jboss.resource.connectionmanager.InternalManagedConnectionPool@6fd06fd0]
      2007-01-23 13:58:08,979 DEBUG [fi.logiasoftware.jca.adapter.GenericManagedConnectionFactory] GenericManagedConnectionFactory createManagedConnection(
      Subject subject, ConnectionRequestInfo o)
      
      


      Any help would be appreciated!

      Br,
      Sami

        • 1. Re: Singleton MDB
          brianbek

          Hi

          Try the property

          @ActivationConfigProperty(propertyName="maxPoolSize", propertyValue="1")


          This is the only property that the MDB's seem to react to!

          /Brian

          • 2. Re: Singleton MDB
            lgsw_sam

            Hi!

            If I use this property

            @ActivationConfigProperty(propertyName="maxPoolSize", propertyValue="1")
            


            I get this warning

            11:22:10,656 WARN [ServiceController] Problem starting service jboss.j2ee:ear=MessageServer.ear,jar=MessageServices.par,name=MessageListenerBean,service=EJB3
            org.jboss.deployment.DeploymentException: Error for ActivationSpec class com.sonicsw.sonicmq.j2ee.jmsra.impl.sonic.SonicActivationSpec as JavaBean; - nested throwable: (java.beans.IntrospectionException: No property found for: maxPoolSize on JavaBean: com.sonicsw.sonicmq.j2ee.jmsra.impl.sonic.SonicActivationSpec@34d234d2)
            
            Caused by:
            java.beans.IntrospectionException: No property found for: maxPoolSize on JavaBean: com.sonicsw.sonicmq.j2ee.jmsra.impl.sonic.SonicActivationSpec@34d234d2
            


            If I use this property

            @ActivationConfigProperty(propertyName = "maxSession", propertyValue = "1")
            


            I get this warning

            11:34:46,828 WARN [ServiceController] Problem starting service jboss.j2ee:ear=MessageServer.ear,jar=MessageServices.par,name=MessageListenerBean,service=EJB3
            org.jboss.deployment.DeploymentException: Error for ActivationSpec class com.sonicsw.sonicmq.j2ee.jmsra.impl.sonic.SonicActivationSpec as JavaBean; - nested throwable: (java.beans.IntrospectionException: No property found for: maxSession on JavaBean: com.sonicsw.sonicmq.j2ee.jmsra.impl.sonic.SonicActivationSpec@4e744e74)
            
            Caused by:
            java.beans.IntrospectionException: No property found for: maxSession on JavaBean: com.sonicsw.sonicmq.j2ee.jmsra.impl.sonic.SonicActivationSpec@4e744e74
            


            Does anyone know another way to implement singleton MDB?

            Br,
            Sami

            • 3. Re: Singleton MDB
              mkleiderman

              This doc: http://docs.jboss.org/ejb3/app-server/reference/build/reference/en/html/jca_inflow.html seems to specify an initial capital letter: MaxPoolSize

              • 4. Re: Singleton MDB
                lgsw_sam

                Hi!
                I have tried it also with MaxPoolSize and it didn't work! Reason seems to be that SonicActivationSpec doesn't have any of these three properties mentioned..

                • 5. Re: Singleton MDB
                  aleksab

                  Use the @Service annotation for a singelton bean.

                  • 6. Re: Singleton MDB
                    wolfc

                     

                    @PoolClass(value=org.jboss.ejb3.StrictMaxPool.class, maxSize=1)

                    Note that this will only make sure there is 1 instance of the MDB alive. It can still be destroyed and recreated. To have a true singleton you should delegate from the MDB to a service bean.

                    • 7. Re: Singleton MDB
                      lgsw_sam

                      Hi wolfc!

                      Thanks for the tip! I'll try that when I have some time!

                      Br,
                      Sami Männistö