3 Replies Latest reply on Feb 1, 2006 7:17 AM by Adrian Brock

    Notification of RA removal

    Dan Salt Newbie


      Platform: JBoss-4.0.3

      I'm currently implementing a JCA Resource Adapter that provides additional functionality for software load balancing. As part of this, when the ManagedConnectionFactory starts up, it establishes a number of "real" connections to the underlying EIS that are then allocated to ManagedConnections (using the chosen LB Algorith) when requests are made by users of the Adapter.

      My question is, is there a mechanism (either within the JCA spec or JBoss implementation) to receive a notification when the Resource Adapter is removed. Preferably I'd want to receive this in the ManagedConnectionFactory, or any class that can indirectly call the MCF. In this way, I can then cleanly close and tidy up the "real" connections.

      Many Thanks,
      Dan Salt.

        • 1. Re: Notification of RA removal
          Dan Salt Newbie

          ... funny how the answer always comes to you 5 seconds after you hit the "send". Well, maybe.

          Am I right in now thinking that I should be providing my own implementation for the JCA 1.5 interface "ResourceAdapter" so that I can write my own "stop()" method and do the work there?

          • 2. Re: Notification of RA removal
            Dan Salt Newbie

            Okay, so that solves half the problem - can anyone help me with the rest.

            For some reason, the ResourceAdapter.stop() is only called when the RA is undeployed, not on ApplicationServer shutdown.

            I've searched on the forums for this (search under ResourceAdapter stop shutdown) and found nothing.

            There is a post on another forum for another AS that has the same problem, and it is cited as a bug, is the same true for this case?


            • 3. Re: Notification of RA removal
              Adrian Brock Master

              It works for me.

              Change: http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossJCAMessageInflowExample

              to have

               public void stop()
               log.info("Stopping", new Throwable("StackTrace"));
               for (Iterator i = activations.entrySet().iterator(); i.hasNext();)

              And then I get:

              07:13:36,969 INFO [RARDeployment] Required license terms exist, view META-INF/r
              a.xml in .../deploy/filexmlrar.rar
              07:13:41,206 INFO [Server] Runtime shutdown hook called, forceHalt: true
              07:13:41,218 INFO [Server] JBoss SHUTDOWN: Undeploying all packages
              07:13:41,240 INFO [FileXMLResourceAdapter] Stopping
              java.lang.Throwable: StackTrace
               at org.jboss.example.FileXMLResourceAdapter.stop(FileXMLResourceAdapter.
               at org.jboss.resource.deployment.RARDeployment.stopService(RARDeployment
               at org.jboss.system.ServiceMBeanSupport.jbossInternalStop(ServiceMBeanSu
               at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMB
               at org.jboss.system.ServiceDynamicMBeanSupport.invoke(ServiceDynamicMBea
               at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:1
               at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)
               at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceControl
               at $Proxy0.stop(Unknown Source)
               at org.jboss.system.ServiceController.stop(ServiceController.java:508)
               at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
               at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
               at java.lang.reflect.Method.invoke(Method.java:585)
               at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
               at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)
               at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
               at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
               at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)
               at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:190)
               at $Proxy40.stop(Unknown Source)
               at org.jboss.deployment.SimpleSubDeployerSupport.stopService(SimpleSubDe
               at org.jboss.deployment.SimpleSubDeployerSupport.stop(SimpleSubDeployerS
               at org.jboss.deployment.MainDeployer.stop(MainDeployer.java:658)
               at org.jboss.deployment.MainDeployer.undeploy(MainDeployer.java:631)
               at org.jboss.deployment.MainDeployer.shutdown(MainDeployer.java:510)