Author: jmesnil
Date: 2010-05-19 07:53:18 -0400 (Wed, 19 May 2010)
New Revision: 9247
Added:
trunk/src/main/org/hornetq/ra/HornetQRAService.java
Modified:
trunk/src/config/jboss-as-5/clustered/hornetq-jboss-beans.xml
trunk/src/config/jboss-as-5/non-clustered/hornetq-jboss-beans.xml
trunk/src/config/jboss-as-6/clustered/hornetq-jboss-beans.xml
trunk/src/config/jboss-as-6/non-clustered/hornetq-jboss-beans.xml
Log:
https://jira.jboss.org/browse/HORNETQ-339: JBoss AS won't shutdown when HornetQ Server
and HornetQ RA are used on that same server
* added a HornetQRAService POJO depending on HornetQServer to ensure that HornetQ Resource
Adapter is stopped before HornetQ server
(else, the RA's invm connections will retry to connect indefinitely and prevent the
AS to shtudown properly)
Modified: trunk/src/config/jboss-as-5/clustered/hornetq-jboss-beans.xml
===================================================================
--- trunk/src/config/jboss-as-5/clustered/hornetq-jboss-beans.xml 2010-05-18 21:16:38 UTC
(rev 9246)
+++ trunk/src/config/jboss-as-5/clustered/hornetq-jboss-beans.xml 2010-05-19 11:53:18 UTC
(rev 9247)
@@ -45,5 +45,17 @@
</parameter>
</constructor>
</bean>
-
+
+ <!-- POJO which ensures HornetQ Resource Adapter is stopped before HornetQServer
-->
+ <!--
-->
+ <!-- update the RA object name if you rename hornetq-ra.rar to jms-ra.rar
-->
+ <bean name="HornetQRAService"
class="org.hornetq.ra.HornetQRAService">
+ <constructor>
+ <parameter>
+ <inject bean="MBeanServer"/>
+ </parameter>
+
<parameter>jboss.jca:name='hornetq-ra.rar',service=RARDeployment</parameter>
+ </constructor>
+ <depends>HornetQServer</depends>
+ </bean>
</deployment>
Modified: trunk/src/config/jboss-as-5/non-clustered/hornetq-jboss-beans.xml
===================================================================
--- trunk/src/config/jboss-as-5/non-clustered/hornetq-jboss-beans.xml 2010-05-18 21:16:38
UTC (rev 9246)
+++ trunk/src/config/jboss-as-5/non-clustered/hornetq-jboss-beans.xml 2010-05-19 11:53:18
UTC (rev 9247)
@@ -45,5 +45,18 @@
</parameter>
</constructor>
</bean>
-
+
+ <!-- POJO which ensures HornetQ Resource Adapter is stopped before HornetQServer
-->
+ <!--
-->
+ <!-- update the RA object name if you rename hornetq-ra.rar to jms-ra.rar
-->
+ <bean name="HornetQRAService"
class="org.hornetq.ra.HornetQRAService">
+ <constructor>
+ <parameter>
+ <inject bean="MBeanServer"/>
+ </parameter>
+
<parameter>jboss.jca:name='hornetq-ra.rar',service=RARDeployment</parameter>
+ </constructor>
+ <depends>HornetQServer</depends>
+ </bean>
+
</deployment>
Modified: trunk/src/config/jboss-as-6/clustered/hornetq-jboss-beans.xml
===================================================================
--- trunk/src/config/jboss-as-6/clustered/hornetq-jboss-beans.xml 2010-05-18 21:16:38 UTC
(rev 9246)
+++ trunk/src/config/jboss-as-6/clustered/hornetq-jboss-beans.xml 2010-05-19 11:53:18 UTC
(rev 9247)
@@ -48,4 +48,15 @@
</constructor>
</bean>
+ <!-- POJO which ensures HornetQ Resource Adapter is stopped before HornetQServer
-->
+ <bean name="HornetQRAService"
class="org.hornetq.ra.HornetQRAService">
+ <constructor>
+ <parameter>
+ <inject bean="MBeanServer"/>
+ </parameter>
+
<parameter>jboss.jca:name='jms-ra.rar',service=RARDeployment</parameter>
+ </constructor>
+ <depends>HornetQServer</depends>
+ </bean>
+
</deployment>
Modified: trunk/src/config/jboss-as-6/non-clustered/hornetq-jboss-beans.xml
===================================================================
--- trunk/src/config/jboss-as-6/non-clustered/hornetq-jboss-beans.xml 2010-05-18 21:16:38
UTC (rev 9246)
+++ trunk/src/config/jboss-as-6/non-clustered/hornetq-jboss-beans.xml 2010-05-19 11:53:18
UTC (rev 9247)
@@ -48,4 +48,14 @@
</constructor>
</bean>
+ <!-- POJO which ensures HornetQ Resource Adapter is stopped before HornetQServer
-->
+ <bean name="HornetQRAService"
class="org.hornetq.ra.HornetQRAService">
+ <constructor>
+ <parameter>
+ <inject bean="MBeanServer"/>
+ </parameter>
+
<parameter>jboss.jca:name='jms-ra.rar',service=RARDeployment</parameter>
+ </constructor>
+ <depends>HornetQServer</depends>
+ </bean>
</deployment>
Added: trunk/src/main/org/hornetq/ra/HornetQRAService.java
===================================================================
--- trunk/src/main/org/hornetq/ra/HornetQRAService.java (rev 0)
+++ trunk/src/main/org/hornetq/ra/HornetQRAService.java 2010-05-19 11:53:18 UTC (rev
9247)
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.ra;
+
+import java.util.Set;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectInstance;
+import javax.management.ObjectName;
+
+import org.hornetq.core.logging.Logger;
+
+/**
+ * A HornetQRAService ensures that HornetQ Resource Adapter will be stopped *before* the
HornetQ server.
+ *
https://jira.jboss.org/browse/HORNETQ-339
+ *
+ * @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a>
+ *
+ *
+ */
+public class HornetQRAService
+{
+ // Constants -----------------------------------------------------
+
+ private static final Logger log = Logger.getLogger(HornetQRAService.class);
+
+ // Attributes ----------------------------------------------------
+
+ private final MBeanServer mBeanServer;
+
+ private final String resourceAdapterObjectName;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ public HornetQRAService(final MBeanServer mBeanServer, final String
resourceAdapterObjectName)
+ {
+ this.mBeanServer = mBeanServer;
+ this.resourceAdapterObjectName = resourceAdapterObjectName;
+ }
+
+ // Public --------------------------------------------------------
+
+ public void stop()
+ {
+ try
+ {
+ ObjectName objectName = new ObjectName(resourceAdapterObjectName);
+ Set<ObjectInstance> mbeanSet = mBeanServer.queryMBeans(objectName, null);
+
+ for (ObjectInstance mbean : mbeanSet)
+ {
+ String stateString = (String)mBeanServer.getAttribute(mbean.getObjectName(),
"StateString");
+
+ if ("Started".equalsIgnoreCase(stateString) ||
"Starting".equalsIgnoreCase(stateString))
+ {
+ mBeanServer.invoke(mbean.getObjectName(), "stop", new Object[0],
new String[0]);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ log.error("Unable to stop HornetQ resource adapter.", e);
+ }
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}