Author: ataylor
Date: 2011-03-04 09:40:28 -0500 (Fri, 04 Mar 2011)
New Revision: 10289
Added:
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/backup-server/
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/backup-server/hornetq-configuration.xml
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/backup-server/hornetq-jms.xml
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/build.bat
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/build.sh
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/build.xml
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/config/
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/config/META-INF/
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/config/META-INF/application.xml
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/config/ant.properties
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/config/jndi.properties
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/live-server/
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/live-server/hornetq-configuration.xml
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/live-server/hornetq-jms.xml
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/server/
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/server/hornetq-configuration.xml
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/server/hornetq-jms.xml
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/server/jms-ds.xml
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/server/ra.xml
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/src/
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/src/org/
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/src/org/hornetq/
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/src/org/hornetq/javaee/
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/src/org/hornetq/javaee/example/
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/src/org/hornetq/javaee/example/MDBRemoteFailoverStaticClientExample.java
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/src/org/hornetq/javaee/example/server/
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/src/org/hornetq/javaee/example/server/MDBRemoteFailoverStaticExample.java
Modified:
branches/Branch_2_2_EAP/examples/javaee/jca-config/server2/jms-remote-ds.xml
branches/Branch_2_2_EAP/examples/javaee/jca-config/server2/ra.xml
branches/Branch_2_2_EAP/examples/javaee/jca-remote/server/jms-ds.xml
branches/Branch_2_2_EAP/examples/javaee/jca-remote/server/ra.xml
branches/Branch_2_2_EAP/src/config/jboss-as-4/clustered/ra.xml
branches/Branch_2_2_EAP/src/config/jboss-as-4/non-clustered/ra.xml
branches/Branch_2_2_EAP/src/config/ra.xml
branches/Branch_2_2_EAP/src/main/org/hornetq/ra/ConnectionFactoryProperties.java
branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQRAMCFProperties.java
branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQRAManagedConnectionFactory.java
branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQResourceAdapter.java
branches/Branch_2_2_EAP/src/main/org/hornetq/ra/Util.java
branches/Branch_2_2_EAP/src/main/org/hornetq/ra/inflow/HornetQActivationSpec.java
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/unit/ra/ResourceAdapterTest.java
Log:
https://issues.jboss.org/browse/JBPAPP-6022 - added support for multiple connectors in
Resource Adapter
Modified: branches/Branch_2_2_EAP/examples/javaee/jca-config/server2/jms-remote-ds.xml
===================================================================
---
branches/Branch_2_2_EAP/examples/javaee/jca-config/server2/jms-remote-ds.xml 2011-03-03
23:51:36 UTC (rev 10288)
+++
branches/Branch_2_2_EAP/examples/javaee/jca-config/server2/jms-remote-ds.xml 2011-03-04
14:40:28 UTC (rev 10289)
@@ -15,8 +15,9 @@
<rar-name>hornetq-ra.rar</rar-name>
<connection-definition>org.hornetq.ra.HornetQRAConnectionFactory</connection-definition>
<config-property name="SessionDefaultType"
type="java.lang.String">javax.jms.Topic</config-property>
+ <!--if we over ride the connector class we must over ride the params too-->
<config-property name="ConnectorClassName"
type="java.lang.String">org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</config-property>
- <config-property name="ConnectionParameters"
type="java.lang.String">port=5445</config-property>
+ <config-property name="ConnectionParameters"
type="java.lang.String">host=localhost;port=5445</config-property>
<max-pool-size>20</max-pool-size>
</tx-connection-factory>
Modified: branches/Branch_2_2_EAP/examples/javaee/jca-config/server2/ra.xml
===================================================================
--- branches/Branch_2_2_EAP/examples/javaee/jca-config/server2/ra.xml 2011-03-03 23:51:36
UTC (rev 10288)
+++ branches/Branch_2_2_EAP/examples/javaee/jca-config/server2/ra.xml 2011-03-04 14:40:28
UTC (rev 10289)
@@ -36,13 +36,19 @@
<resourceadapter>
<resourceadapter-class>org.hornetq.ra.HornetQResourceAdapter</resourceadapter-class>
<config-property>
- <description>The transport type</description>
+ <description>
+ The transport type. Multiple connectors can be configured by using a comma
separated list,
+ i.e.
org.hornetq.core.remoting.impl.invm.InVMConnectorFactory,org.hornetq.core.remoting.impl.invm.InVMConnectorFactory.
+ </description>
<config-property-name>ConnectorClassName</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</config-property-value>
</config-property>
<config-property>
- <description>The transport configuration. These values must be in the form
of key=val;key=val;</description>
+ <description>The transport configuration. These values must be in the form
of key=val;key=val;,
+ if multiple connectors are used then each set must be separated by a comma
i.e. host=host1;port=5445,host=host2;port=5446.
+ Each set of params maps to the connector classname specified.
+ </description>
<config-property-name>ConnectionParameters</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>host=127.0.0.1;port=5445</config-property-value>
Modified: branches/Branch_2_2_EAP/examples/javaee/jca-remote/server/jms-ds.xml
===================================================================
--- branches/Branch_2_2_EAP/examples/javaee/jca-remote/server/jms-ds.xml 2011-03-03
23:51:36 UTC (rev 10288)
+++ branches/Branch_2_2_EAP/examples/javaee/jca-remote/server/jms-ds.xml 2011-03-04
14:40:28 UTC (rev 10289)
@@ -29,6 +29,7 @@
<rar-name>hornetq-ra.rar</rar-name>
<connection-definition>org.hornetq.ra.HornetQRAConnectionFactory</connection-definition>
<config-property name="SessionDefaultType"
type="java.lang.String">javax.jms.Topic</config-property>
+ <!--if we over ride the connector class we must over ride the params too-->
<config-property name="ConnectorClassName"
type="java.lang.String">org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</config-property>
<config-property name="ConnectionParameters"
type="java.lang.String">host=127.0.0.1;port=5446</config-property>
<max-pool-size>20</max-pool-size>
Modified: branches/Branch_2_2_EAP/examples/javaee/jca-remote/server/ra.xml
===================================================================
--- branches/Branch_2_2_EAP/examples/javaee/jca-remote/server/ra.xml 2011-03-03 23:51:36
UTC (rev 10288)
+++ branches/Branch_2_2_EAP/examples/javaee/jca-remote/server/ra.xml 2011-03-04 14:40:28
UTC (rev 10289)
@@ -49,13 +49,19 @@
<resourceadapter>
<resourceadapter-class>org.hornetq.ra.HornetQResourceAdapter</resourceadapter-class>
<config-property>
- <description>The transport type</description>
+ <description>
+ The transport type. Multiple connectors can be configured by using a comma
separated list,
+ i.e.
org.hornetq.core.remoting.impl.invm.InVMConnectorFactory,org.hornetq.core.remoting.impl.invm.InVMConnectorFactory.
+ </description>
<config-property-name>ConnectorClassName</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</config-property-value>
</config-property>
<config-property>
- <description>The transport configuration. These values must be in the form
of key=val;key=val;</description>
+ <description>The transport configuration. These values must be in the form
of key=val;key=val;,
+ if multiple connectors are used then each set must be separated by a comma
i.e. host=host1;port=5445,host=host2;port=5446.
+ Each set of params maps to the connector classname specified.
+ </description>
<config-property-name>ConnectionParameters</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>host=127.0.0.1;port=5446</config-property-value>
Added:
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/backup-server/hornetq-configuration.xml
===================================================================
---
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/backup-server/hornetq-configuration.xml
(rev 0)
+++
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/backup-server/hornetq-configuration.xml 2011-03-04
14:40:28 UTC (rev 10289)
@@ -0,0 +1,108 @@
+<!--
+ ~ Copyright 2009 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.
+ -->
+
+<configuration xmlns="urn:hornetq"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:hornetq
/schema/hornetq-configuration.xsd">
+
+ <name>HornetQ.main.config</name>
+
+ <clustered>true</clustered>
+
+ <failover-on-shutdown>true</failover-on-shutdown>
+
+ <backup>true</backup>
+
+ <shared-store>true</shared-store>
+
+ <!--journal directories-->
+
<large-messages-directory>/tmp/shared/hornetq-data/large-messages</large-messages-directory>
+
<bindings-directory>/tmp/shared/hornetq-data/bindings</bindings-directory>
+ <journal-directory>/tmp/shared/hornetq-data/journal</journal-directory>
+ <paging-directory>/tmp/shared/hornetq-data/paging</paging-directory>
+
+ <!-- Connectors -->
+
+ <connectors>
+ <connector name="netty-connector">
+
<factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
+ <param key="host"
value="${jboss.bind.address:localhost}"/>
+ <param key="port"
value="${hornetq.remoting.netty.port:5445}"/>
+ </connector>
+ <connector name="in-vm">
+
<factory-class>org.hornetq.core.remoting.impl.invm.InVMConnectorFactory</factory-class>
+ <param key="server-id"
value="${hornetq.server-id:0}"/>
+ </connector>
+ </connectors>
+
+ <!-- Acceptors -->
+ <acceptors>
+ <!-- In VM acceptor -->
+ <acceptor name="in-vm">
+
<factory-class>org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory</factory-class>
+ <param key="server-id"
value="${hornetq.server-id:0}"/>
+ </acceptor>
+ <acceptor name="netty-acceptor">
+
<factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
+ <param key="host"
value="${jboss.bind.address:localhost}"/>
+ <param key="port"
value="${hornetq.remoting.netty.port:5445}"/>
+ </acceptor>
+ </acceptors>
+
+ <broadcast-groups>
+ <broadcast-group name="bg-group1">
+ <group-address>231.7.7.7</group-address>
+ <group-port>9876</group-port>
+ <broadcast-period>1000</broadcast-period>
+ <connector-ref>netty-connector</connector-ref>
+ </broadcast-group>
+ </broadcast-groups>
+
+ <discovery-groups>
+ <discovery-group name="dg-group1">
+ <group-address>231.7.7.7</group-address>
+ <group-port>9876</group-port>
+ <refresh-timeout>60000</refresh-timeout>
+ </discovery-group>
+ </discovery-groups>
+
+ <cluster-connections>
+ <cluster-connection name="my-cluster">
+ <address>jms</address>
+ <connector-ref>netty-connector</connector-ref>
+ <discovery-group-ref discovery-group-name="dg-group1"/>
+ </cluster-connection>
+ </cluster-connections>
+ <!-- Other config -->
+
+ <security-settings>
+ <!--security for example queue-->
+ <security-setting match="jms.queue.inQueue">
+ <permission type="createDurableQueue" roles="guest"/>
+ <permission type="deleteDurableQueue" roles="guest"/>
+ <permission type="createNonDurableQueue"
roles="guest"/>
+ <permission type="deleteNonDurableQueue"
roles="guest"/>
+ <permission type="consume" roles="guest"/>
+ <permission type="send" roles="guest"/>
+ </security-setting>
+ <security-setting match="jms.queue.outQueue">
+ <permission type="createDurableQueue" roles="guest"/>
+ <permission type="deleteDurableQueue" roles="guest"/>
+ <permission type="createNonDurableQueue"
roles="guest"/>
+ <permission type="deleteNonDurableQueue"
roles="guest"/>
+ <permission type="consume" roles="guest"/>
+ <permission type="send" roles="guest"/>
+ </security-setting>
+ </security-settings>
+
+</configuration>
Added:
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/backup-server/hornetq-jms.xml
===================================================================
---
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/backup-server/hornetq-jms.xml
(rev 0)
+++
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/backup-server/hornetq-jms.xml 2011-03-04
14:40:28 UTC (rev 10289)
@@ -0,0 +1,49 @@
+<!--
+ ~ Copyright 2009 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.
+ -->
+
+<configuration xmlns="urn:hornetq"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
+ <!--the connection factory used by the example-->
+ <connection-factory name="ConnectionFactory">
+ <connectors>
+ <connector-ref connector-name="netty-connector"/>
+ </connectors>
+
+ <entries>
+ <entry name="ConnectionFactory"/>
+ </entries>
+
+ <ha>true</ha>
+ <!-- Pause 1 second between connect attempts -->
+ <retry-interval>1000</retry-interval>
+
+ <!-- Multiply subsequent reconnect pauses by this multiplier. This can be used
to
+ implement an exponential back-off. For our purposes we just set to 1.0 so each
reconnect
+ pause is the same length -->
+ <retry-interval-multiplier>1.0</retry-interval-multiplier>
+
+ <!-- Try reconnecting an unlimited number of times (-1 means
"unlimited") -->
+ <reconnect-attempts>-1</reconnect-attempts>
+ </connection-factory>
+
+ <!--the queue used by the example-->
+ <queue name="inQueue">
+ <entry name="/queue/inQueue"/>
+ </queue>
+
+ <queue name="outQueue">
+ <entry name="/queue/outQueue"/>
+ </queue>
+
+</configuration>
Copied: branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/build.bat (from
rev 10288, branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/build.bat)
===================================================================
--- branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/build.bat
(rev 0)
+++
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/build.bat 2011-03-04
14:40:28 UTC (rev 10289)
@@ -0,0 +1,13 @@
+@echo off
+
+set "OVERRIDE_ANT_HOME=..\..\..\tools\ant"
+
+if exist "..\..\..\src\bin\build.bat" (
+ rem running from TRUNK
+ call ..\..\..\src\bin\build.bat %*
+) else (
+ rem running from the distro
+ call ..\..\..\bin\build.bat %*
+)
+
+set "OVERRIDE_ANT_HOME="
Copied: branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/build.sh (from
rev 10288, branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/build.sh)
===================================================================
--- branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/build.sh
(rev 0)
+++ branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/build.sh 2011-03-04
14:40:28 UTC (rev 10289)
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+OVERRIDE_ANT_HOME=../../../tools/ant
+export OVERRIDE_ANT_HOME
+
+if [ -f "../../../src/bin/build.sh" ]; then
+ # running from TRUNK
+ ../../../src/bin/build.sh "$@"
+else
+ # running from the distro
+ ../../../bin/build.sh "$@"
+fi
+
+
+
Copied: branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/build.xml (from
rev 10288, branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/build.xml)
===================================================================
--- branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/build.xml
(rev 0)
+++
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/build.xml 2011-03-04
14:40:28 UTC (rev 10289)
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2009 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.
+ -->
+
+<project default="run" name="HornetQ Java EE MDB with remote failover
Config Example">
+
+ <import file="../common/build.xml"/>
+ <property file="../../common/config/server.properties"/>
+
+ <property name="example.live.server.dir"
value="live-server"/>
+ <property name="example.backup.server.dir"
value="backup-server"/>
+ <target name="run" depends="validate-jboss,compile">
+
+ <property name="serverclasspath"
refid="jms.runtime.classpath"/>
+
+ <java
classname="org.hornetq.javaee.example.MDBRemoteFailoverStaticClientExample"
fork="true">
+ <jvmarg
value="-Dhornetq.example.server.classpath=${serverclasspath}"/>
+ <jvmarg value="-Dhornetq.example.server.args=${server.args}"/>
+ <jvmarg
value="-Dhornetq.example.logserveroutput=${hornetq.example.logserveroutput}"/>
+ <jvmarg
value="-Dhornetq.example.runServer=${hornetq.example.runServer}"/>
+ <arg line="${hornetq.example.beans.file}"/>
+ <sysproperty key="java.library.path"
value="${java.library.path}${path.separator}${aio.library.path}"/>
+ <classpath refid="jms.runtime.classpath"/>
+ </java>
+ </target>
+
+
+ <target name="copy-resources">
+ <copy todir="${example-profile}/deploy/jms-ra.rar/META-INF"
overwrite="true">
+ <fileset dir="${example.server.dir}">
+ <include name="ra.xml"/>
+ </fileset>
+ </copy>
+ </target>
+
+ <target name="deployLive" depends="validate-jboss,
copy-live-profile">
+ <property name="example-profile"
value="${jboss.home}/server/${example.name}-live"/>
+ <copy todir="${example-profile}/deploy/hornetq"
overwrite="true">
+ <fileset dir="${example.live.server.dir}"/>
+ </copy>
+ <exec dir="${jboss.home}/bin" executable="sh"
osfamily="unix">
+ <arg line="run.sh -Djboss.service.binding.set=ports-01 -c
${example.name}-live"/>
+ </exec>
+ <exec dir="${jboss.home}/bin" executable="cmd"
osfamily="windows">
+ <arg line="/c run.bat -Djboss.service.binding.set=ports-01 -c
${example.name}-live"/>
+ </exec>
+ </target>
+
+ <target name="copy-live-profile" depends="live.profile.check"
unless="donot.copy.profile">
+ <property name="profile"
value="${jboss.home}/server/default"/>
+ <property name="example-profile"
value="${jboss.home}/server/${example.name}-live"/>
+ <property name="deploy.dir"
value="${example-profile}/deploy/"/>
+ <mkdir dir="${example-profile}"/>
+ <copy todir="${example-profile}">
+ <fileset dir="${profile}">
+ <exclude name="**/*hornetq-configuration.xml"/>
+ <exclude name="**/*hornetq-jms.xml"/>
+ </fileset>
+ </copy>
+ </target>
+
+ <target name="live.profile.check">
+ <property name="example-profile"
value="${jboss.home}/server/${example.name}-live"/>
+ <condition property="donot.copy.profile">
+ <available file="${example-profile}" type="dir"/>
+ </condition>
+ </target>
+
+ <target name="deployBackup" depends="validate-jboss,
copy-backup-profile">
+ <property name="example-profile"
value="${jboss.home}/server/${example.name}-backup"/>
+ <copy todir="${example-profile}/deploy/hornetq"
overwrite="true">
+ <fileset dir="${example.backup.server.dir}"/>
+ </copy>
+ <exec dir="${jboss.home}/bin" executable="sh"
osfamily="unix">
+ <arg line="run.sh -Djboss.service.binding.set=ports-02 -c
${example.name}-backup"/>
+ </exec>
+ <exec dir="${jboss.home}/bin" executable="cmd"
osfamily="windows">
+ <arg line="/c run.bat -Djboss.service.binding.set=ports-02 -c
${example.name}-backup"/>
+ </exec>
+ </target>
+
+ <target name="copy-backup-profile"
depends="backup.profile.check" unless="donot.copy.profile">
+ <property name="profile"
value="${jboss.home}/server/default"/>
+ <property name="example-profile"
value="${jboss.home}/server/${example.name}-backup"/>
+ <property name="deploy.dir"
value="${example-profile}/deploy/"/>
+ <mkdir dir="${example-profile}"/>
+ <copy todir="${example-profile}">
+ <fileset dir="${profile}">
+ <exclude name="**/*hornetq-configuration.xml"/>
+ </fileset>
+ </copy>
+ </target>
+
+ <target name="backup.profile.check">
+ <property name="example-profile"
value="${jboss.home}/server/${example.name}-backup"/>
+ <condition property="donot.copy.profile">
+ <available file="${example-profile}" type="dir"/>
+ </condition>
+ </target>
+
+</project>
\ No newline at end of file
Added:
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/config/META-INF/application.xml
===================================================================
---
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/config/META-INF/application.xml
(rev 0)
+++
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/config/META-INF/application.xml 2011-03-04
14:40:28 UTC (rev 10289)
@@ -0,0 +1,28 @@
+<!--
+ ~ Copyright 2009 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.
+ -->
+
+<application>
+ <display-name>My Application</display-name>
+
+ <module>
+ <web>
+ <web-uri>mdb-remote-failover-static-example.war</web-uri>
+ <context-root>/hornetq</context-root>
+ </web>
+ </module>
+ <module>
+ <java>mdb-remote-failover-static-example.jar</java>
+ </module>
+
+
+</application>
Added:
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/config/ant.properties
===================================================================
---
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/config/ant.properties
(rev 0)
+++
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/config/ant.properties 2011-03-04
14:40:28 UTC (rev 10289)
@@ -0,0 +1,14 @@
+#
+# Copyright 2009 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.
+#
+
+example.name=mdb-remote-failover-static
\ No newline at end of file
Added:
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/config/jndi.properties
===================================================================
---
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/config/jndi.properties
(rev 0)
+++
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/config/jndi.properties 2011-03-04
14:40:28 UTC (rev 10289)
@@ -0,0 +1,16 @@
+#
+# Copyright 2009 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.
+#
+
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.provider.url=jnp://localhost:1199
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
Added:
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/live-server/hornetq-configuration.xml
===================================================================
---
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/live-server/hornetq-configuration.xml
(rev 0)
+++
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/live-server/hornetq-configuration.xml 2011-03-04
14:40:28 UTC (rev 10289)
@@ -0,0 +1,109 @@
+<!--
+ ~ Copyright 2009 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.
+ -->
+
+<configuration xmlns="urn:hornetq"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:hornetq
/schema/hornetq-configuration.xsd">
+
+ <name>HornetQ.main.config</name>
+
+ <clustered>true</clustered>
+
+ <!--we shutdown the server process so need this set to true-->
+ <failover-on-shutdown>true</failover-on-shutdown>
+
+ <shared-store>true</shared-store>
+
+ <!--journal directories-->
+
<large-messages-directory>/tmp/shared/hornetq-data/large-messages</large-messages-directory>
+
<bindings-directory>/tmp/shared/hornetq-data/bindings</bindings-directory>
+ <journal-directory>/tmp/shared/hornetq-data/journal</journal-directory>
+ <paging-directory>/tmp/shared/hornetq-data/paging</paging-directory>
+
+ <!-- Connectors -->
+
+ <connectors>
+ <connector name="netty-connector">
+
<factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
+ <param key="host"
value="${jboss.bind.address:localhost}"/>
+ <param key="port"
value="${hornetq.remoting.netty.port:5445}"/>
+ </connector>
+
+ <connector name="in-vm">
+
<factory-class>org.hornetq.core.remoting.impl.invm.InVMConnectorFactory</factory-class>
+ <param key="server-id"
value="${hornetq.server-id:0}"/>
+ </connector>
+ </connectors>
+
+ <!-- Acceptors -->
+ <acceptors>
+
+ <!-- In VM acceptor -->
+ <acceptor name="in-vm">
+
<factory-class>org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory</factory-class>
+ <param key="server-id"
value="${hornetq.server-id:0}"/>
+ </acceptor>
+ <acceptor name="netty-acceptor">
+
<factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
+ <param key="host"
value="${jboss.bind.address:localhost}"/>
+ <param key="port"
value="${hornetq.remoting.netty.port:5445}"/>
+ </acceptor>
+ </acceptors>
+
+ <broadcast-groups>
+ <broadcast-group name="bg-group1">
+ <group-address>231.7.7.7</group-address>
+ <group-port>9876</group-port>
+ <broadcast-period>1000</broadcast-period>
+ <connector-ref>netty-connector</connector-ref>
+ </broadcast-group>
+ </broadcast-groups>
+
+ <discovery-groups>
+ <discovery-group name="dg-group1">
+ <group-address>231.7.7.7</group-address>
+ <group-port>9876</group-port>
+ <refresh-timeout>60000</refresh-timeout>
+ </discovery-group>
+ </discovery-groups>
+
+ <cluster-connections>
+ <cluster-connection name="my-cluster">
+ <address>jms</address>
+ <connector-ref>netty-connector</connector-ref>
+ <discovery-group-ref discovery-group-name="dg-group1"/>
+ </cluster-connection>
+ </cluster-connections>
+ <!-- Other config -->
+
+ <security-settings>
+ <!--security for example queue-->
+ <security-setting match="jms.queue.inQueue">
+ <permission type="createDurableQueue" roles="guest"/>
+ <permission type="deleteDurableQueue" roles="guest"/>
+ <permission type="createNonDurableQueue"
roles="guest"/>
+ <permission type="deleteNonDurableQueue"
roles="guest"/>
+ <permission type="consume" roles="guest"/>
+ <permission type="send" roles="guest"/>
+ </security-setting>
+ <security-setting match="jms.queue.outQueue">
+ <permission type="createDurableQueue" roles="guest"/>
+ <permission type="deleteDurableQueue" roles="guest"/>
+ <permission type="createNonDurableQueue"
roles="guest"/>
+ <permission type="deleteNonDurableQueue"
roles="guest"/>
+ <permission type="consume" roles="guest"/>
+ <permission type="send" roles="guest"/>
+ </security-setting>
+ </security-settings>
+
+</configuration>
Added:
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/live-server/hornetq-jms.xml
===================================================================
---
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/live-server/hornetq-jms.xml
(rev 0)
+++
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/live-server/hornetq-jms.xml 2011-03-04
14:40:28 UTC (rev 10289)
@@ -0,0 +1,49 @@
+<!--
+ ~ Copyright 2009 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.
+ -->
+
+<configuration xmlns="urn:hornetq"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
+ <!--the connection factory used by the example-->
+ <connection-factory name="ConnectionFactory">
+ <connectors>
+ <connector-ref connector-name="netty-connector"/>
+ </connectors>
+
+ <entries>
+ <entry name="ConnectionFactory"/>
+ </entries>
+
+ <ha>true</ha>
+ <!-- Pause 1 second between connect attempts -->
+ <retry-interval>1000</retry-interval>
+
+ <!-- Multiply subsequent reconnect pauses by this multiplier. This can be used
to
+ implement an exponential back-off. For our purposes we just set to 1.0 so each
reconnect
+ pause is the same length -->
+ <retry-interval-multiplier>1.0</retry-interval-multiplier>
+
+ <!-- Try reconnecting an unlimited number of times (-1 means
"unlimited") -->
+ <reconnect-attempts>-1</reconnect-attempts>
+ </connection-factory>
+
+ <!--the queue used by the example-->
+ <queue name="inQueue">
+ <entry name="/queue/inQueue"/>
+ </queue>
+
+ <queue name="outQueue">
+ <entry name="/queue/outQueue"/>
+ </queue>
+
+</configuration>
Added:
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/server/hornetq-configuration.xml
===================================================================
---
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/server/hornetq-configuration.xml
(rev 0)
+++
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/server/hornetq-configuration.xml 2011-03-04
14:40:28 UTC (rev 10289)
@@ -0,0 +1,63 @@
+<!--
+ ~ Copyright 2009 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.
+ -->
+
+<configuration xmlns="urn:hornetq"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:hornetq
/schema/hornetq-configuration.xsd">
+
+ <name>HornetQ.main.config</name>
+
+
<bindings-directory>${jboss.server.data.dir}/messaging/bindings</bindings-directory>
+
+
<journal-directory>${jboss.server.data.dir}/messaging/journal</journal-directory>
+
+
<large-messages-directory>${jboss.server.data.dir}/messaging/largemessages</large-messages-directory>
+
+
<paging-directory>${jboss.server.data.dir}/messaging/paging</paging-directory>
+
+ <!-- Connectors -->
+ <connectors>
+ <connector name="netty">
+
<factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
+ </connector>
+
+ <connector name="in-vm">
+
<factory-class>org.hornetq.core.remoting.impl.invm.InVMConnectorFactory</factory-class>
+ </connector>
+
+ </connectors>
+
+ <!-- Acceptors -->
+ <acceptors>
+ <!-- In VM acceptor -->
+ <acceptor name="in-vm">
+
<factory-class>org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory</factory-class>
+ <param key="server-id" value="0"/>
+ </acceptor>
+
+ <!-- Netty TCP Acceptor -->
+ <acceptor name="netty">
+
<factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
+ <param key="port"
value="${hornetq.remoting.netty.port:5445}"/>
+ </acceptor>
+ </acceptors>
+
+ <security-settings>
+ <security-setting match="jms.queue.#">
+ <permission type="consume" roles="guest,publisher"/>
+ <permission type="send" roles="guest,publisher"/>
+ </security-setting>
+ </security-settings>
+
+
+</configuration>
Added:
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/server/hornetq-jms.xml
===================================================================
---
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/server/hornetq-jms.xml
(rev 0)
+++
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/server/hornetq-jms.xml 2011-03-04
14:40:28 UTC (rev 10289)
@@ -0,0 +1,33 @@
+<!--
+ ~ Copyright 2009 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.
+ -->
+
+<configuration xmlns="urn:hornetq"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
+ <connection-factory name="ConnectionFactory">
+ <connectors>
+ <connector-ref connector-name="netty"/>
+ </connectors>
+ <entries>
+ <entry name="ConnectionFactory"/>
+ <entry name="XAConnectionFactory"/>
+ </entries>
+ </connection-factory>
+
+ <queue name="A">
+ <entry name="/queue/A"/>
+ </queue>
+ <queue name="B">
+ <entry name="/queue/B"/>
+ </queue>
+</configuration>
\ No newline at end of file
Added:
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/server/jms-ds.xml
===================================================================
--- branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/server/jms-ds.xml
(rev 0)
+++
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/server/jms-ds.xml 2011-03-04
14:40:28 UTC (rev 10289)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+
+<!--
+ ~ Copyright 2009 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.
+ -->
+
+
+<!-- This file will be deployed by the target deploy on build.xml -->
+<connection-factories>
+
+
+ <!--
+ JMS XA Resource adapter, use this for outbound JMS connections.
+ Inbound connections are defined at the @MDB activaction or at the resource-adapter
properties.
+ -->
+ <tx-connection-factory>
+ <jndi-name>RemoteJmsXA</jndi-name>
+ <xa-transaction/>
+ <rar-name>hornetq-ra.rar</rar-name>
+
<connection-definition>org.hornetq.ra.HornetQRAConnectionFactory</connection-definition>
+ <config-property name="SessionDefaultType"
type="java.lang.String">javax.jms.Queue</config-property>
+ <config-property name="hA"
type="java.lang.Boolean">true</config-property>
+ </tx-connection-factory>
+
+
+</connection-factories>
Added: branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/server/ra.xml
===================================================================
--- branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/server/ra.xml
(rev 0)
+++
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/server/ra.xml 2011-03-04
14:40:28 UTC (rev 10289)
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ Copyright 2009 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.
+ -->
+
+<!-- This file will be installed by the example mdb-remote/build.xml, deploy target.
+ This is an example of how you could change the default configuration of a resource
adapter
+ -->
+
+<connector
xmlns="http://java.sun.com/xml/ns/j2ee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+
http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"
+ version="1.5">
+
+ <description>HornetQ 2.0 Resource Adapter Alternate
Configuration</description>
+ <display-name>HornetQ 2.0 Resource Adapter Alternate
Configuration</display-name>
+
+ <vendor-name>Red Hat Middleware LLC</vendor-name>
+ <eis-type>JMS 1.1 Server</eis-type>
+ <resourceadapter-version>1.0</resourceadapter-version>
+
+ <license>
+ <description>
+Copyright 2009 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.
+ </description>
+ <license-required>true</license-required>
+ </license>
+
+ <resourceadapter>
+ <config-property>
+ <description>
+ The transport type. Multiple connectors can be configured by using a comma
separated list,
+ i.e.
org.hornetq.core.remoting.impl.invm.InVMConnectorFactory,org.hornetq.core.remoting.impl.invm.InVMConnectorFactory.
+ </description>
+ <config-property-name>ConnectorClassName</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+
<config-property-value>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory,org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</config-property-value>
+ </config-property>
+ <config-property>
+ <description>The transport configuration. These values must be in the form
of key=val;key=val;,
+ if multiple connectors are used then each set must be separated by a comma
i.e. host=host1;port=5445,host=host2;port=5446.
+ Each set of params maps to the connector classname specified.
+ </description>
+ <config-property-name>ConnectionParameters</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+
<config-property-value>host=127.0.0.1;port=5445,host=127.0.0.1;port=5446</config-property-value>
+ </config-property>
+ <config-property>
+ <description>Do we support HA</description>
+ <config-property-name>hA</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>true</config-property-value>
+ </config-property>
+ <config-property>
+ <description>reconnect attempts</description>
+ <config-property-name>reconnectAttempts</config-property-name>
+ <config-property-type>java.lang.Integer</config-property-type>
+ <config-property-value>-1</config-property-value>
+ </config-property>
+
+ <outbound-resourceadapter>
+ <connection-definition>
+
<managedconnectionfactory-class>org.hornetq.ra.HornetQRAManagedConnectionFactory</managedconnectionfactory-class>
+
+ <config-property>
+ <description>The default session type</description>
+
<config-property-name>SessionDefaultType</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+
<config-property-value>javax.jms.Queue</config-property-value>
+ </config-property>
+ <config-property>
+ <description>Try to obtain a lock within specified number of
seconds; less than or equal to 0 disable this functionality</description>
+ <config-property-name>UseTryLock</config-property-name>
+
<config-property-type>java.lang.Integer</config-property-type>
+ <config-property-value>0</config-property-value>
+ </config-property>
+
+
<connectionfactory-interface>org.hornetq.ra.HornetQRAConnectionFactory</connectionfactory-interface>
+
<connectionfactory-impl-class>org.hornetq.ra.HornetQRAConnectionFactoryImpl</connectionfactory-impl-class>
+ <connection-interface>javax.jms.Session</connection-interface>
+
<connection-impl-class>org.hornetq.ra.HornetQRASession</connection-impl-class>
+ </connection-definition>
+ <transaction-support>XATransaction</transaction-support>
+ <authentication-mechanism>
+
<authentication-mechanism-type>BasicPassword</authentication-mechanism-type>
+
<credential-interface>javax.resource.spi.security.PasswordCredential</credential-interface>
+ </authentication-mechanism>
+ <reauthentication-support>false</reauthentication-support>
+ </outbound-resourceadapter>
+
+ <inbound-resourceadapter>
+ <messageadapter>
+ <messagelistener>
+
<messagelistener-type>javax.jms.MessageListener</messagelistener-type>
+ <activationspec>
+
<activationspec-class>org.hornetq.ra.inflow.HornetQActivationSpec</activationspec-class>
+ <required-config-property>
+
<config-property-name>destination</config-property-name>
+ </required-config-property>
+ </activationspec>
+ </messagelistener>
+ </messageadapter>
+ </inbound-resourceadapter>
+
+ </resourceadapter>
+</connector>
Copied:
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/src/org/hornetq/javaee/example/MDBRemoteFailoverStaticClientExample.java
(from rev 10288,
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/src/org/hornetq/javaee/example/MDBRemoteFailoverClientExample.java)
===================================================================
---
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/src/org/hornetq/javaee/example/MDBRemoteFailoverStaticClientExample.java
(rev 0)
+++
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/src/org/hornetq/javaee/example/MDBRemoteFailoverStaticClientExample.java 2011-03-04
14:40:28 UTC (rev 10289)
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2009 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.javaee.example;
+
+import javax.jms.*;
+import javax.naming.InitialContext;
+
+/**
+ * @author <a href="mailto:andy.taylor@jboss.com">Andy Taylor</a>
+ * Date: 2/24/11
+ * Time: 2:44 PM
+ */
+public class MDBRemoteFailoverStaticClientExample
+{
+ public static void main(String[] args) throws Exception
+ {
+ Connection connection = null;
+ InitialContext initialContext = null;
+ try
+ {
+ //Step 1. Create an initial context to perform the JNDI lookup.
+ initialContext = new InitialContext();
+
+ //Step 2. Perfom a lookup on the queue
+ Queue queue = (Queue) initialContext.lookup("/queue/inQueue");
+
+ //Step 3. Perform a lookup on the Connection Factory
+ ConnectionFactory cf = (ConnectionFactory)
initialContext.lookup("/ConnectionFactory");
+
+ //Step 4.Create a JMS Connection
+ connection = cf.createConnection();
+
+ //Step 5. Create a JMS Session
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ //Step 6. Create a JMS Message Producer
+ MessageProducer producer = session.createProducer(queue);
+
+ //Step 7. Create a Text Message
+ TextMessage message = session.createTextMessage("This is a text
message");
+
+ System.out.println("Sent message: " + message.getText());
+
+ //Step 8. Send the Message
+ producer.send(message);
+
+ //Step 15. We lookup the reply queue
+ queue = (Queue) initialContext.lookup("/queue/outQueue");
+
+ //Step 16. We create a JMS message consumer
+ MessageConsumer messageConsumer = session.createConsumer(queue);
+
+ //Step 17. We start the connedction so we can receive messages
+ connection.start();
+
+ //Step 18. We receive the message and print it out
+ message = (TextMessage) messageConsumer.receive(5000);
+
+ System.out.println("message.getText() = " + message.getText());
+
+ System.out.println("Kill Live Server and press enter");
+
+ System.in.read();
+
+ //Step 7. Create a Text Message
+ message = session.createTextMessage("This is another text message");
+
+ System.out.println("Sent message: " + message.getText());
+
+ //Step 8. Send the Message
+ producer.send(message);
+
+ //Step 16. We create a JMS message consumer
+ messageConsumer = session.createConsumer(queue);
+
+ //Step 18. We receive the message and print it out
+ message = (TextMessage) messageConsumer.receive(5000);
+
+ System.out.println("message.getText() = " + message.getText());
+
+ }
+ finally
+ {
+ //Step 19. Be sure to close our JMS resources!
+ if (initialContext != null)
+ {
+ initialContext.close();
+ }
+ if(connection != null)
+ {
+ connection.close();
+ }
+ }
+ }
+}
Copied:
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/src/org/hornetq/javaee/example/server/MDBRemoteFailoverStaticExample.java
(from rev 10288,
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/src/org/hornetq/javaee/example/server/MDBRemoteFailoverExample.java)
===================================================================
---
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/src/org/hornetq/javaee/example/server/MDBRemoteFailoverStaticExample.java
(rev 0)
+++
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover-static/src/org/hornetq/javaee/example/server/MDBRemoteFailoverStaticExample.java 2011-03-04
14:40:28 UTC (rev 10289)
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2009 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.javaee.example.server;
+
+import org.hornetq.api.jms.HornetQJMSClient;
+import org.jboss.ejb3.annotation.ResourceAdapter;
+
+import javax.annotation.Resource;
+import javax.ejb.*;
+import javax.jms.*;
+
+/**
+ * @author <a href="mailto:andy.taylor@jboss.com">Andy Taylor</a>
+ * Date: 2/24/11
+ * Time: 2:44 PM
+ */
+@MessageDriven(name = "MDBRemoteFailoverExample",
+ activationConfig =
+ {
+ @ActivationConfigProperty(propertyName =
"destinationType", propertyValue = "javax.jms.Queue"),
+ @ActivationConfigProperty(propertyName = "destination",
propertyValue = "queue/inQueue") ,
+ @ActivationConfigProperty(propertyName = "hA",
propertyValue = "true")
+ })
+@TransactionManagement(value= TransactionManagementType.CONTAINER)
+@TransactionAttribute(value= TransactionAttributeType.REQUIRED)
+(a)ResourceAdapter("hornetq-ra.rar")
+public class MDBRemoteFailoverStaticExample implements MessageListener
+{
+
+ @Resource(mappedName = "java:RemoteJmsXA")
+ ConnectionFactory connectionFactory;
+ Queue replyQueue;
+
+ public void onMessage(Message message)
+ {
+ Connection conn = null;
+ try
+ {
+ replyQueue = HornetQJMSClient.createQueue("outQueue");
+ //Step 9. We know the client is sending a text message so we cast
+ TextMessage textMessage = (TextMessage)message;
+
+ //Step 10. get the text from the message.
+ String text = textMessage.getText();
+
+ System.out.println("message " + text);
+
+ //Step 11. we create a JMS connection
+ conn = connectionFactory.createConnection();
+
+ //Step 12. We create a JMS session
+ Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ //Step 13. we create a producer for the reply queue
+ MessageProducer producer = sess.createProducer(replyQueue);
+
+ //Step 14. we create a message and send it
+ producer.send(sess.createTextMessage("this is a reply"));
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ finally
+ {
+ if(conn != null)
+ {
+ try
+ {
+ conn.close();
+ }
+ catch (JMSException e)
+ {
+ }
+ }
+ }
+ }
+}
Modified: branches/Branch_2_2_EAP/src/config/jboss-as-4/clustered/ra.xml
===================================================================
--- branches/Branch_2_2_EAP/src/config/jboss-as-4/clustered/ra.xml 2011-03-03 23:51:36 UTC
(rev 10288)
+++ branches/Branch_2_2_EAP/src/config/jboss-as-4/clustered/ra.xml 2011-03-04 14:40:28 UTC
(rev 10289)
@@ -47,13 +47,19 @@
<resourceadapter>
<resourceadapter-class>org.hornetq.ra.HornetQResourceAdapter</resourceadapter-class>
<config-property>
- <description>The transport type</description>
+ <description>
+ The transport type. Multiple connectors can be configured by using a comma
separated list,
+ i.e.
org.hornetq.core.remoting.impl.invm.InVMConnectorFactory,org.hornetq.core.remoting.impl.invm.InVMConnectorFactory.
+ </description>
<config-property-name>ConnectorClassName</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</config-property-value>
</config-property>
<config-property>
- <description>The transport configuration. These values must be in the form
of key=val;key=val;</description>
+ <description>The transport configuration. These values must be in the form
of key=val;key=val;,
+ if multiple connectors are used then each set must be separated by a comma
i.e. host=host1;port=5445,host=host2;port=5446.
+ Each set of params maps to the connector classname specified.
+ </description>
<config-property-name>ConnectionParameters</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>host=localhost;port=5445</config-property-value>
Modified: branches/Branch_2_2_EAP/src/config/jboss-as-4/non-clustered/ra.xml
===================================================================
--- branches/Branch_2_2_EAP/src/config/jboss-as-4/non-clustered/ra.xml 2011-03-03 23:51:36
UTC (rev 10288)
+++ branches/Branch_2_2_EAP/src/config/jboss-as-4/non-clustered/ra.xml 2011-03-04 14:40:28
UTC (rev 10289)
@@ -47,13 +47,19 @@
<resourceadapter>
<resourceadapter-class>org.hornetq.ra.HornetQResourceAdapter</resourceadapter-class>
<config-property>
- <description>The transport type</description>
+ <description>
+ The transport type. Multiple connectors can be configured by using a comma
separated list,
+ i.e.
org.hornetq.core.remoting.impl.invm.InVMConnectorFactory,org.hornetq.core.remoting.impl.invm.InVMConnectorFactory.
+ </description>
<config-property-name>ConnectorClassName</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</config-property-value>
</config-property>
<config-property>
- <description>The transport configuration. These values must be in the form
of key=val;key=val;</description>
+ <description>The transport configuration. These values must be in the form
of key=val;key=val;,
+ if multiple connectors are used then each set must be separated by a comma
i.e. host=host1;port=5445,host=host2;port=5446.
+ Each set of params maps to the connector classname specified.
+ </description>
<config-property-name>ConnectionParameters</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>host=localhost;port=5445</config-property-value>
Modified: branches/Branch_2_2_EAP/src/config/ra.xml
===================================================================
--- branches/Branch_2_2_EAP/src/config/ra.xml 2011-03-03 23:51:36 UTC (rev 10288)
+++ branches/Branch_2_2_EAP/src/config/ra.xml 2011-03-04 14:40:28 UTC (rev 10289)
@@ -34,13 +34,19 @@
<resourceadapter>
<resourceadapter-class>org.hornetq.ra.HornetQResourceAdapter</resourceadapter-class>
<config-property>
- <description>The transport type</description>
+ <description>
+ The transport type. Multiple connectors can be configured by using a comma
separated list,
+ i.e.
org.hornetq.core.remoting.impl.invm.InVMConnectorFactory,org.hornetq.core.remoting.impl.invm.InVMConnectorFactory.
+ </description>
<config-property-name>ConnectorClassName</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>org.hornetq.core.remoting.impl.invm.InVMConnectorFactory</config-property-value>
</config-property>
<config-property>
- <description>The transport configuration. These values must be in the form
of key=val;key=val;</description>
+ <description>The transport configuration. These values must be in the form
of key=val;key=val;,
+ if multiple connectors are used then each set must be separated by a comma
i.e. host=host1;port=5445,host=host2;port=5446.
+ Each set of params maps to the connector classname specified.
+ </description>
<config-property-name>ConnectionParameters</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>server-id=0</config-property-value>
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/ra/ConnectionFactoryProperties.java
===================================================================
---
branches/Branch_2_2_EAP/src/main/org/hornetq/ra/ConnectionFactoryProperties.java 2011-03-03
23:51:36 UTC (rev 10288)
+++
branches/Branch_2_2_EAP/src/main/org/hornetq/ra/ConnectionFactoryProperties.java 2011-03-04
14:40:28 UTC (rev 10289)
@@ -12,6 +12,7 @@
*/
package org.hornetq.ra;
+import java.util.List;
import java.util.Map;
import org.hornetq.core.logging.Logger;
@@ -36,12 +37,12 @@
/**
* The transport type, changing the default configured from the RA
*/
- private String connectorClassName;
+ private List<String> connectorClassName;
/**
* The transport config, changing the default configured from the RA
*/
- private Map<String, Object> connectionParameters;
+ private List<Map<String, Object>> connectionParameters;
private Boolean ha;
@@ -102,23 +103,23 @@
/**
* @return the transportType
*/
- public String getConnectorClassName()
+ public List<String> getParsedConnectorClassNames()
{
return connectorClassName;
}
- public Map<String, Object> getParsedConnectionParameters()
+ public List<Map<String, Object>> getParsedConnectionParameters()
{
return connectionParameters;
}
- public void setParsedConnectionParameters(final Map<String, Object>
connectionParameters)
+ public void setParsedConnectionParameters(final List<Map<String, Object>>
connectionParameters)
{
this.connectionParameters = connectionParameters;
hasBeenUpdated = true;
}
- public void setConnectorClassName(final String value)
+ public void setParsedConnectorClassNames(final List<String> value)
{
connectorClassName = value;
hasBeenUpdated = true;
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQRAMCFProperties.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQRAMCFProperties.java 2011-03-03
23:51:36 UTC (rev 10288)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQRAMCFProperties.java 2011-03-04
14:40:28 UTC (rev 10289)
@@ -56,6 +56,9 @@
*/
private static final String TOPIC_TYPE = Topic.class.getName();
+
+ private String strConnectorClassName;
+
public String strConnectionParameters;
/**
@@ -96,6 +99,22 @@
return type;
}
+ public String getConnectorClassName()
+ {
+ return strConnectorClassName;
+ }
+
+ public void setConnectorClassName(final String connectorClassName)
+ {
+ if (HornetQRAMCFProperties.trace)
+ {
+ HornetQRAMCFProperties.log.trace("setConnectorClassName(" +
connectorClassName + ")");
+ }
+
+ strConnectorClassName = connectorClassName;
+
+
setParsedConnectorClassNames(Util.parseConnectorConnectorConfig(connectorClassName));
+ }
/**
* @return the connectionParameters
*/
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQRAManagedConnectionFactory.java
===================================================================
---
branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQRAManagedConnectionFactory.java 2011-03-03
23:51:36 UTC (rev 10288)
+++
branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQRAManagedConnectionFactory.java 2011-03-04
14:40:28 UTC (rev 10289)
@@ -15,6 +15,7 @@
import java.io.PrintWriter;
import java.util.Iterator;
+import java.util.List;
import java.util.Set;
import javax.jms.ConnectionMetaData;
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQResourceAdapter.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQResourceAdapter.java 2011-03-03
23:51:36 UTC (rev 10288)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQResourceAdapter.java 2011-03-04
14:40:28 UTC (rev 10289)
@@ -14,6 +14,7 @@
import java.io.Serializable;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -82,7 +83,13 @@
*/
private String unparsedProperties;
+
/**
+ * The resource adapter connector classnames before parsing
+ */
+ private String unparsedConnectors;
+
+ /**
* Have the factory been configured
*/
private final AtomicBoolean configured;
@@ -242,13 +249,14 @@
{
HornetQResourceAdapter.log.trace("setTransportType(" +
connectorClassName + ")");
}
+ unparsedConnectors = connectorClassName;
- raProperties.setConnectorClassName(connectorClassName);
+
raProperties.setParsedConnectorClassNames(Util.parseConnectorConnectorConfig(connectorClassName));
}
public String getConnectorClassName()
{
- return raProperties.getConnectorClassName();
+ return unparsedConnectors;
}
public String getConnectionParameters()
@@ -1344,12 +1352,12 @@
return defaultHornetQConnectionFactory;
}
- //TODO - currently RA only allows a single target server to be specified we should
allow a list of servers to be passed in
public HornetQConnectionFactory createHornetQConnectionFactory(final
ConnectionFactoryProperties overrideProperties)
{
HornetQConnectionFactory cf;
- String connectorClassName = overrideProperties.getConnectorClassName() != null ?
overrideProperties.getConnectorClassName()
- :
getConnectorClassName();
+ List<String> connectorClassName =
overrideProperties.getParsedConnectorClassNames() != null ?
overrideProperties.getParsedConnectorClassNames()
+ :
raProperties.getParsedConnectorClassNames();
+
String discoveryAddress = overrideProperties.getDiscoveryAddress() != null ?
overrideProperties.getDiscoveryAddress()
:
getDiscoveryAddress();
@@ -1362,26 +1370,41 @@
if (connectorClassName != null)
{
- Map<String, Object> connectionParams;
-
if(raProperties.getConnectorClassName().equals(overrideProperties.getConnectorClassName()))
+ TransportConfiguration[] transportConfigurations = new
TransportConfiguration[connectorClassName.size()];
+
+ List<Map<String, Object>> connectionParams;
+ if(overrideProperties.getParsedConnectorClassNames() != null)
{
-
- connectionParams =
-
overrideConnectionParameters(raProperties.getParsedConnectionParameters(),overrideProperties.getParsedConnectionParameters());
+ connectionParams = overrideProperties.getParsedConnectionParameters();
}
else
{
- connectionParams = overrideProperties.getParsedConnectionParameters();
+ connectionParams = raProperties.getParsedConnectionParameters();
}
- TransportConfiguration transportConf = new
TransportConfiguration(connectorClassName, connectionParams);
+
+ for (int i = 0; i < connectorClassName.size(); i++)
+ {
+ TransportConfiguration tc;
+ if(connectionParams == null || i >= connectionParams.size())
+ {
+ tc = new TransportConfiguration(connectorClassName.get(i));
+ log.debug("No connector params provided using default");
+ }
+ else
+ {
+ tc = new TransportConfiguration(connectorClassName.get(i),
connectionParams.get(i));
+ }
+
+ transportConfigurations[i] = tc;
+ }
if (ha)
{
- cf = HornetQJMSClient.createConnectionFactoryWithHA(JMSFactoryType.XA_CF, new
TransportConfiguration[] {transportConf});
+ cf = HornetQJMSClient.createConnectionFactoryWithHA(JMSFactoryType.XA_CF,
transportConfigurations);
}
else
{
- cf = HornetQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.XA_CF,
new TransportConfiguration[] {transportConf});
+ cf = HornetQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.XA_CF,
transportConfigurations);
}
}
else if (discoveryAddress != null)
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/ra/Util.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/ra/Util.java 2011-03-03 23:51:36 UTC (rev
10288)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/ra/Util.java 2011-03-04 14:40:28 UTC (rev
10289)
@@ -13,7 +13,9 @@
package org.hornetq.ra;
import java.lang.reflect.Method;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import javax.naming.Context;
@@ -174,26 +176,49 @@
return context.lookup(name);
}
- public static Map<String, Object> parseConfig(final String config)
+ public static List<Map<String, Object>> parseConfig(final String config)
{
- HashMap<String, Object> result = new HashMap<String, Object>();
+ List<Map<String, Object>> result =new ArrayList<Map<String,
Object>>();
- String elements[] = config.split(";");
+ String[] topElements = config.split(",");
- for (String element : elements)
+ for (String topElement : topElements)
{
- String expression[] = element.split("=");
+ HashMap<String, Object> map = new HashMap<String, Object>();
+ result.add(map);
- if (expression.length != 2)
+ String elements[] = topElement.split(";");
+
+ for (String element : elements)
{
- throw new IllegalArgumentException("Invalid expression " + element
+ " at " + config);
+ String expression[] = element.split("=");
+
+ if (expression.length != 2)
+ {
+ throw new IllegalArgumentException("Invalid expression " +
element + " at " + config);
+ }
+
+ map.put(expression[0].trim(), expression[1].trim());
}
-
- result.put(expression[0].trim(), expression[1].trim());
}
+
return result;
}
+
+ public static List<String> parseConnectorConnectorConfig(String config)
+ {
+ List<String> res = new ArrayList<String>();
+
+ String[] elements = config.split(",");
+
+ for (String element : elements)
+ {
+ res.add(element.trim());
+ }
+
+ return res;
+ }
/** The Resource adapter can't depend on any provider's specific library.
Because of that we use reflection to locate the
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/ra/inflow/HornetQActivationSpec.java
===================================================================
---
branches/Branch_2_2_EAP/src/main/org/hornetq/ra/inflow/HornetQActivationSpec.java 2011-03-03
23:51:36 UTC (rev 10288)
+++
branches/Branch_2_2_EAP/src/main/org/hornetq/ra/inflow/HornetQActivationSpec.java 2011-03-04
14:40:28 UTC (rev 10289)
@@ -13,6 +13,7 @@
package org.hornetq.ra.inflow;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import javax.jms.Session;
@@ -46,8 +47,7 @@
/** Whether trace is enabled */
private static boolean trace = HornetQActivationSpec.log.isTraceEnabled();
- /** The transport config, changing the default configured from the RA */
- private Map<String, Object> connectionParameters = new HashMap<String,
Object>();
+ public String strConnectorClassName;
public String strConnectionParameters;
@@ -607,6 +607,23 @@
}
}
+ public String getConnectorClassName()
+ {
+ return strConnectorClassName;
+ }
+
+ public void setConnectorClassName(final String connectorClassName)
+ {
+ if (HornetQActivationSpec.trace)
+ {
+ HornetQActivationSpec.log.trace("setConnectorClassName(" +
connectorClassName + ")");
+ }
+
+ strConnectorClassName = connectorClassName;
+
+
setParsedConnectorClassNames(Util.parseConnectorConnectorConfig(connectorClassName));
+ }
+
/**
* @return the connectionParameters
*/
@@ -615,16 +632,10 @@
return strConnectionParameters;
}
- @Override
- public Map<String, Object> getParsedConnectionParameters()
- {
- return connectionParameters;
- }
-
public void setConnectionParameters(final String configuration)
{
strConnectionParameters = configuration;
- connectionParameters = Util.parseConfig(configuration);
+ setParsedConnectionParameters(Util.parseConfig(configuration));
}
/**
Modified:
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/unit/ra/ResourceAdapterTest.java
===================================================================
---
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/unit/ra/ResourceAdapterTest.java 2011-03-03
23:51:36 UTC (rev 10288)
+++
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/unit/ra/ResourceAdapterTest.java 2011-03-04
14:40:28 UTC (rev 10289)
@@ -14,6 +14,9 @@
package org.hornetq.tests.unit.ra;
import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Timer;
import javax.jms.Connection;
@@ -31,6 +34,7 @@
import junit.framework.Assert;
+import org.hornetq.api.core.TransportConfiguration;
import org.hornetq.api.core.client.ClientSession;
import org.hornetq.api.core.client.ClientSessionFactory;
import org.hornetq.api.core.client.HornetQClient;
@@ -269,7 +273,9 @@
HornetQResourceAdapter ra = new HornetQResourceAdapter();
ra.setConnectorClassName(InVMConnector.class.getName());
ConnectionFactoryProperties connectionFactoryProperties = new
ConnectionFactoryProperties();
- connectionFactoryProperties.setConnectorClassName(NettyConnector.class.getName());
+ ArrayList<String> value = new ArrayList<String>();
+ value.add(NettyConnector.class.getName());
+ connectionFactoryProperties.setParsedConnectorClassNames(value);
HornetQConnectionFactory factory =
ra.createHornetQConnectionFactory(connectionFactoryProperties);
HornetQConnectionFactory defaultFactory = ra.getDefaultHornetQConnectionFactory();
Assert.assertNotSame(factory, defaultFactory);
@@ -287,6 +293,105 @@
Assert.assertNotSame(factory, defaultFactory);
}
+ public void testCreateConnectionFactoryMultipleConnectors()
+ {
+ HornetQResourceAdapter ra = new HornetQResourceAdapter();
+ ra.setConnectorClassName(NETTY_CONNECTOR_FACTORY + "," +
INVM_CONNECTOR_FACTORY + "," + NETTY_CONNECTOR_FACTORY);
+ HornetQConnectionFactory factory = ra.createHornetQConnectionFactory(new
ConnectionFactoryProperties());
+ TransportConfiguration[] configurations =
factory.getServerLocator().getStaticTransportConfigurations();
+ assertNotNull(configurations);
+ assertEquals(3, configurations.length);
+ assertEquals(NETTY_CONNECTOR_FACTORY, configurations[0].getFactoryClassName());
+ assertEquals(0, configurations[0].getParams().size());
+ assertEquals(INVM_CONNECTOR_FACTORY, configurations[1].getFactoryClassName());
+ assertEquals(0, configurations[1].getParams().size());
+ assertEquals(NETTY_CONNECTOR_FACTORY, configurations[2].getFactoryClassName());
+ assertEquals(0, configurations[2].getParams().size());
+ }
+
+ public void testCreateConnectionFactoryMultipleConnectorsAndParams()
+ {
+ HornetQResourceAdapter ra = new HornetQResourceAdapter();
+ ra.setConnectorClassName(NETTY_CONNECTOR_FACTORY + "," +
INVM_CONNECTOR_FACTORY + "," + NETTY_CONNECTOR_FACTORY);
+ ra.setConnectionParameters("host=host1;port=5445, serverid=0,
host=host2;port=5446");
+ HornetQConnectionFactory factory = ra.createHornetQConnectionFactory(new
ConnectionFactoryProperties());
+ TransportConfiguration[] configurations =
factory.getServerLocator().getStaticTransportConfigurations();
+ assertNotNull(configurations);
+ assertEquals(3, configurations.length);
+ assertEquals(NETTY_CONNECTOR_FACTORY, configurations[0].getFactoryClassName());
+ assertEquals(2, configurations[0].getParams().size());
+ assertEquals("host1",
configurations[0].getParams().get("host"));
+ assertEquals("5445",
configurations[0].getParams().get("port"));
+ assertEquals(INVM_CONNECTOR_FACTORY, configurations[1].getFactoryClassName());
+ assertEquals(1, configurations[1].getParams().size());
+ assertEquals("0",
configurations[1].getParams().get("serverid"));
+ assertEquals(NETTY_CONNECTOR_FACTORY, configurations[2].getFactoryClassName());
+ assertEquals(2, configurations[2].getParams().size());
+ assertEquals("host2",
configurations[2].getParams().get("host"));
+ assertEquals("5446",
configurations[2].getParams().get("port"));
+ }
+
+ public void testCreateConnectionFactoryMultipleConnectorsOverride()
+ {
+ HornetQResourceAdapter ra = new HornetQResourceAdapter();
+ ra.setConnectorClassName(NETTY_CONNECTOR_FACTORY + "," +
INVM_CONNECTOR_FACTORY + "," + NETTY_CONNECTOR_FACTORY);
+ ConnectionFactoryProperties overrideProperties = new
ConnectionFactoryProperties();
+ ArrayList<String> value = new ArrayList<String>();
+ value.add(INVM_CONNECTOR_FACTORY);
+ value.add(NETTY_CONNECTOR_FACTORY);
+ value.add(INVM_CONNECTOR_FACTORY);
+ overrideProperties.setParsedConnectorClassNames(value);
+ HornetQConnectionFactory factory =
ra.createHornetQConnectionFactory(overrideProperties);
+ TransportConfiguration[] configurations =
factory.getServerLocator().getStaticTransportConfigurations();
+ assertNotNull(configurations);
+ assertEquals(3, configurations.length);
+ assertEquals(INVM_CONNECTOR_FACTORY, configurations[0].getFactoryClassName());
+ assertEquals(0, configurations[0].getParams().size());
+ assertEquals(NETTY_CONNECTOR_FACTORY, configurations[1].getFactoryClassName());
+ assertEquals(0, configurations[1].getParams().size());
+ assertEquals(INVM_CONNECTOR_FACTORY, configurations[2].getFactoryClassName());
+ assertEquals(0, configurations[2].getParams().size());
+ }
+
+ public void testCreateConnectionFactoryMultipleConnectorsOverrideAndParams()
+ {
+ HornetQResourceAdapter ra = new HornetQResourceAdapter();
+ ra.setConnectorClassName(NETTY_CONNECTOR_FACTORY + "," +
INVM_CONNECTOR_FACTORY + "," + NETTY_CONNECTOR_FACTORY);
+ ra.setConnectionParameters("host=host1;port=5445, serverid=0,
host=host2;port=5446");
+ ConnectionFactoryProperties overrideProperties = new
ConnectionFactoryProperties();
+ ArrayList<String> value = new ArrayList<String>();
+ value.add(INVM_CONNECTOR_FACTORY);
+ value.add(NETTY_CONNECTOR_FACTORY);
+ value.add(INVM_CONNECTOR_FACTORY);
+ overrideProperties.setParsedConnectorClassNames(value);
+ ArrayList<Map<String, Object>> connectionParameters = new
ArrayList<Map<String, Object>>();
+ Map<String, Object> map1 = new HashMap<String, Object>();
+ map1.put("serverid", "0");
+ connectionParameters.add(map1);
+ Map<String, Object> map2 = new HashMap<String, Object>();
+ map2.put("host", "myhost");
+ map2.put("port", "5445");
+ connectionParameters.add(map2);
+ Map<String, Object> map3 = new HashMap<String, Object>();
+ map3.put("serverid", "1");
+ connectionParameters.add(map3);
+ overrideProperties.setParsedConnectionParameters(connectionParameters);
+ HornetQConnectionFactory factory =
ra.createHornetQConnectionFactory(overrideProperties);
+ TransportConfiguration[] configurations =
factory.getServerLocator().getStaticTransportConfigurations();
+ assertNotNull(configurations);
+ assertEquals(3, configurations.length);
+ assertEquals(INVM_CONNECTOR_FACTORY, configurations[0].getFactoryClassName());
+ assertEquals(1, configurations[0].getParams().size());
+ assertEquals("0",
configurations[0].getParams().get("serverid"));
+ assertEquals(NETTY_CONNECTOR_FACTORY, configurations[1].getFactoryClassName());
+ assertEquals(2, configurations[1].getParams().size());
+ assertEquals("myhost",
configurations[1].getParams().get("host"));
+ assertEquals("5445",
configurations[1].getParams().get("port"));
+ assertEquals(INVM_CONNECTOR_FACTORY, configurations[2].getFactoryClassName());
+ assertEquals(1, configurations[2].getParams().size());
+ assertEquals("1",
configurations[2].getParams().get("serverid"));
+ }
+
public void testCreateConnectionFactoryThrowsException() throws Exception
{
HornetQResourceAdapter ra = new HornetQResourceAdapter();