Author: ataylor
Date: 2010-05-24 09:05:46 -0400 (Mon, 24 May 2010)
New Revision: 9254
Added:
trunk/examples/javaee/jca-remote/
trunk/examples/javaee/jca-remote/build.bat
trunk/examples/javaee/jca-remote/build.sh
trunk/examples/javaee/jca-remote/build.xml
trunk/examples/javaee/jca-remote/config/
trunk/examples/javaee/jca-remote/config/META-INF/
trunk/examples/javaee/jca-remote/config/META-INF/application.xml
trunk/examples/javaee/jca-remote/config/ant.properties
trunk/examples/javaee/jca-remote/config/client.jndi.properties
trunk/examples/javaee/jca-remote/readme.html
trunk/examples/javaee/jca-remote/server/
trunk/examples/javaee/jca-remote/server/hornetq-configuration.xml
trunk/examples/javaee/jca-remote/server/hornetq-jms.xml
trunk/examples/javaee/jca-remote/server/jms-ds.xml
trunk/examples/javaee/jca-remote/server/ra.xml
trunk/examples/javaee/jca-remote/server0/
trunk/examples/javaee/jca-remote/server0/client-jndi.properties
trunk/examples/javaee/jca-remote/server0/hornetq-beans.xml
trunk/examples/javaee/jca-remote/server0/hornetq-configuration.xml
trunk/examples/javaee/jca-remote/server0/hornetq-jms.xml
trunk/examples/javaee/jca-remote/server0/hornetq-users.xml
trunk/examples/javaee/jca-remote/src/
trunk/examples/javaee/jca-remote/src/org/
trunk/examples/javaee/jca-remote/src/org/hornetq/
trunk/examples/javaee/jca-remote/src/org/hornetq/javaee/
trunk/examples/javaee/jca-remote/src/org/hornetq/javaee/example/
trunk/examples/javaee/jca-remote/src/org/hornetq/javaee/example/MDBRemoteServerClientExample.java
trunk/examples/javaee/jca-remote/src/org/hornetq/javaee/example/server/
trunk/examples/javaee/jca-remote/src/org/hornetq/javaee/example/server/MDBQueue.java
Modified:
trunk/docs/user-manual/en/appserver-integration.xml
trunk/docs/user-manual/en/examples.xml
trunk/examples/javaee/common/build.xml
Log:
added jca example showing connecting to remote HQ server and doc updates
Modified: trunk/docs/user-manual/en/appserver-integration.xml
===================================================================
--- trunk/docs/user-manual/en/appserver-integration.xml 2010-05-21 22:52:11 UTC (rev
9253)
+++ trunk/docs/user-manual/en/appserver-integration.xml 2010-05-24 13:05:46 UTC (rev
9254)
@@ -793,6 +793,49 @@
</table>
</section>
+ <section>
+ <title>Configuring the adapter to use a standalone HornetQ
Server</title>
+ <para>Sometime you may want your messaging server on a different machine
or separate from the application server.</para>
+ <para>To do this you will need to configure both the incoming and
outgoing adapter.</para>
+ <para>To configure MDB's to consume messages from a remote HornetQ
server you need to configure the ra.xml file
+ which can be found under
<literal>deploy/hornet-ra.rar/META-INF</literal>. Simply configure the
transport to
+ use a netty connector (instead of the invm connector) and configure its
transport params. Heres an example of
+ what this would look like:</para>
+ <programlisting>
+
<resourceadapter-class>org.hornetq.ra.HornetQResourceAdapter</resourceadapter-class>
+ <config-property>
+ <description>The transport
type</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>
+
<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>
+ </config-property>
+ </programlisting>
+ <para>This configures the resource adapter to connect to a server running
on localhosr listening on port 5446</para>
+ <para>You will also need to configure any outbound connections to also
connect to this server. This can be done
+ by either configuring the jms-ds.xml file found under
<literal>deploy/hornetq.sar</literal> or creating a
+ new configuration file and making sure the filename ends in
-ds.xml</para>
+ <para>The following example shows a sample configuration</para>
+ <programlisting>
+ <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.Topic</config-property>
+ <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>
+ </tx-connection-factory>
+ </programlisting>
+ <para>Again this will connect to the HornetQ server running on localhost
and listening on port 5446. JEE components
+ can access this by using JNDI and looking up
<literal>java:/RemoteJmsXA</literal></para>
+ </section>
</section>
<section>
<title>High Availability JNDI (HA-JNDI)</title>
Modified: trunk/docs/user-manual/en/examples.xml
===================================================================
--- trunk/docs/user-manual/en/examples.xml 2010-05-21 22:52:11 UTC (rev 9253)
+++ trunk/docs/user-manual/en/examples.xml 2010-05-24 13:05:46 UTC (rev 9254)
@@ -530,6 +530,10 @@
<para>This example demonstrates how to configure several properties on
the HornetQ JCA
resource adaptor.</para>
</section>
+ <section>
+ <title>Resource Adapter Remote Server Configuration</title>
+ <para>This example demonstrates how to configure the HornetQ resource
adapter to talk to a remote HornetQ server</para>
+ </section>
<section id="examples.javaee.jms-bridge">
<title>JMS Bridge</title>
<para>An example demonstrating the use of the HornetQ JMS
bridge.</para>
Modified: trunk/examples/javaee/common/build.xml
===================================================================
--- trunk/examples/javaee/common/build.xml 2010-05-21 22:52:11 UTC (rev 9253)
+++ trunk/examples/javaee/common/build.xml 2010-05-24 13:05:46 UTC (rev 9254)
@@ -86,6 +86,7 @@
failonerror="${javac.fail.onerror}">
<src>
<pathelement path="${src.dir}"/>
+ <pathelement path="../../common/src"/>
</src>
<classpath refid="jms.compilation.classpath"/>
</javac>
@@ -115,10 +116,10 @@
<target name="deploy" depends="validate-jboss, copy-profile,
copy-resources, ear">
<property name="example-profile"
value="${jboss.home}/server/${example.name}-example-profile"/>
- <copy todir="${example-profile}/deploy/hornetq.sar">
+ <copy todir="${example-profile}/deploy/hornetq.sar"
overwrite="true">
<fileset dir="${example.server.dir}"/>
</copy>
- <copy todir="${example-profile}/deploy/">
+ <copy todir="${example-profile}/deploy/"
overwrite="true">
<fileset dir="${build.dir}">
<include name="${example.name}-example.ear"/>
<exclude name="**/data/**"/>
Copied: trunk/examples/javaee/jca-remote/build.bat (from rev 9253,
trunk/examples/javaee/jca-config/build.bat)
===================================================================
--- trunk/examples/javaee/jca-remote/build.bat (rev 0)
+++ trunk/examples/javaee/jca-remote/build.bat 2010-05-24 13:05:46 UTC (rev 9254)
@@ -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: trunk/examples/javaee/jca-remote/build.sh (from rev 9253,
trunk/examples/javaee/jca-config/build.sh)
===================================================================
--- trunk/examples/javaee/jca-remote/build.sh (rev 0)
+++ trunk/examples/javaee/jca-remote/build.sh 2010-05-24 13:05:46 UTC (rev 9254)
@@ -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: trunk/examples/javaee/jca-remote/build.xml (from rev 9253,
trunk/examples/javaee/jca-config/build.xml)
===================================================================
--- trunk/examples/javaee/jca-remote/build.xml (rev 0)
+++ trunk/examples/javaee/jca-remote/build.xml 2010-05-24 13:05:46 UTC (rev 9254)
@@ -0,0 +1,43 @@
+<?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 JCA Config
Example">
+
+ <import file="../common/build.xml"/>
+ <property file="../../common/config/server.properties"/>
+ <target name="run" depends="validate-jboss,compile">
+
+ <property name="serverclasspath"
refid="jms.runtime.classpath"/>
+
+ <java
classname="org.hornetq.javaee.example.MDBRemoteServerClientExample"
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/hornetq-ra.rar/META-INF"
overwrite="true">
+ <fileset dir="${example.server.dir}">
+ <include name="ra.xml"/>
+ </fileset>
+ </copy>
+ </target>
+
+</project>
\ No newline at end of file
Copied: trunk/examples/javaee/jca-remote/config/META-INF/application.xml (from rev 9253,
trunk/examples/javaee/jca-config/config/META-INF/application.xml)
===================================================================
--- trunk/examples/javaee/jca-remote/config/META-INF/application.xml
(rev 0)
+++ trunk/examples/javaee/jca-remote/config/META-INF/application.xml 2010-05-24 13:05:46
UTC (rev 9254)
@@ -0,0 +1,27 @@
+<!--
+ ~ 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>jca-remote-example.war</web-uri>
+ <context-root>/hornetq</context-root>
+ </web>
+ </module>
+ <module>
+ <java>jca-remote-example.jar</java>
+ </module>
+
+
+</application>
Copied: trunk/examples/javaee/jca-remote/config/ant.properties (from rev 9253,
trunk/examples/javaee/jca-config/config/ant.properties)
===================================================================
--- trunk/examples/javaee/jca-remote/config/ant.properties (rev
0)
+++ trunk/examples/javaee/jca-remote/config/ant.properties 2010-05-24 13:05:46 UTC (rev
9254)
@@ -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=jca-remote
\ No newline at end of file
Copied: trunk/examples/javaee/jca-remote/config/client.jndi.properties (from rev 9253,
trunk/examples/javaee/jca-config/config/jndi.properties)
===================================================================
--- trunk/examples/javaee/jca-remote/config/client.jndi.properties
(rev 0)
+++ trunk/examples/javaee/jca-remote/config/client.jndi.properties 2010-05-24 13:05:46 UTC
(rev 9254)
@@ -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:1099
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
Copied: trunk/examples/javaee/jca-remote/readme.html (from rev 9253,
trunk/examples/javaee/jca-config/readme.html)
===================================================================
--- trunk/examples/javaee/jca-remote/readme.html (rev 0)
+++ trunk/examples/javaee/jca-remote/readme.html 2010-05-24 13:05:46 UTC (rev 9254)
@@ -0,0 +1,140 @@
+<html>
+ <head>
+ <title>HornetQ Java EE JCA Remote Server Configuration Example</title>
+ <link rel="stylesheet" type="text/css"
href="../../common/common.css" />
+ <link rel="stylesheet" type="text/css"
href="../../common/prettify.css" />
+ <script type="text/javascript"
src="../../common/prettify.js"></script>
+ </head>
+ <body onload="prettyPrint()">
+ <h1>Java EE Resource Adapter Remote Server Configuration Example</h1>
+ <p>This example demonstrates how to configure the Resource adapter to connect
to a remote HornetQ server</p>
+ <p>This example is composed of a message driven bean and a client<p>
+ <p>MDBRemoteServerClientExample will send a message to the MDB via a queue and
wait for the MDB to send a response via
+ a reply queue</p>
+ <h2>configuring the incoming Adapter</h2>
+ <p>MDB's will consume messages via the incoming resource adapter. This can
be found under hornetq-ra.rar/META-INF
+ and is called ra.xml. simply update the connector to use the netty connector instead
of an invm connector and configure the transport params, as such</p>
+ <pre class="prettyprint">
+
<resourceadapter-class>org.hornetq.ra.HornetQResourceAdapter</resourceadapter-class>
+ <config-property>
+ <description>The transport
type</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>
+
<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>
+ </config-property>
+ </pre>
+
+ <h2>configuring the outgoing Adapter</h2>
+ <p>This configures a JCA connection factory the JEE components can use to look
up the remote HornetQ Server</p>
+ <p>The default connection factory is found in jms-ds.xml. In this example we
have changed this and renamed it as follows</p>
+
+ <pre class="prettyprint">
+ <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.Topic</config-property>
+ <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>
+ </tx-connection-factory>
+ </pre>
+ <h2>Example step-by-step</h2>
+ <p><i>To deploy and start the HornetQ server, simply type
<code>./build.sh</code> (or <code>build.bat</code> on windows)
from the example directory</i></p>
+ <p><i>After the HornetQ server has started start the Application server,
simply type <code>./build.sh deploy</code> (or <code>build.bat
deploy</code> on windows) from the example directory</i></p>
+ <p><i> ** make sure that JBOSS_HOME is set to the JBoss installation
directory</i></p>
+
+ <ol>
+ <li>First we need to get an initial context so we can look-up the EJB on
the second server from JNDI. This initial context will get it's properties from the
<code>jndi.properties</code> file in the directory
<code>config</code></li>
+ <pre class="prettyprint">
+ initialContext = new InitialContext();
+ </pre>
+ <li>Look up the MDB's queue</li>
+ <pre class="prettyprint">
+ Queue queue = (Queue) initialContext.lookup("queue/mdbQueue");
+ </pre>
+ <li>look up the connection factory</li>
+ <pre class="prettyprint">
+ ConnectionFactory cf = (ConnectionFactory)
initialContext.lookup("ConnectionFactory");
+ </pre>
+ <li>We then create a connection</li>
+ <pre class="prettyprint">
+ connection = cf.createConnection();
+ </pre>
+ <li>we then create a session</li>
+ <pre class="prettyprint">
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ </pre>
+ <li>we now create a message producer to send the message</li>
+ <pre class="prettyprint">
+ MessageProducer producer = session.createProducer(queue);
+ </pre>
+ <li>create a text message and send it</li>
+ <pre class="prettyprint">
+ producer.send(session.createTextMessage("a message"));
+ </pre>
+ <li>The MDB receives the text message</li>
+ <pre class="prettyprint">
+ TextMessage tm = (TextMessage)message;
+ </pre>
+ <li>The MDB looks up the reply queue</li>
+ <pre class="prettyprint">
+ Queue destQueue = HornetQJMSClient.createQueue("mdbReplyQueue");
+ </pre>
+ <li>The MDB creates a connection</li>
+ <pre class="prettyprint">
+ Connection connection = connectionFactory.createConnection();
+ </pre>
+ <li>The MDB creates a session</li>
+ <pre class="prettyprint">
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ </pre>
+ <li>The MDB creates a message producer to send the message</li>
+ <pre class="prettyprint">
+ MessageProducer producer = session.createProducer(destQueue);
+ </pre>
+ <li>The MDB creates and sends a text message</li>
+ <pre class="prettyprint">
+ producer.send(session.createTextMessage("A reply message"));
+ </pre>
+ <li>The MDB closes the connection which returns it to the pool</li>
+ <pre class="prettyprint">
+ connection.close();
+ </pre>
+ <li>The client now looks up the reply queue</li>
+ <pre class="prettyprint">
+ Queue replyQueue = (Queue)
initialContext.lookup("queue/mdbReplyQueue");
+ </pre>
+ <li>and creates a message consumer to receive the message</li>
+ <pre class="prettyprint">
+ MessageConsumer consumer = session.createConsumer(replyQueue);
+ </pre>
+ <li>starting the connection starts delivery</li>
+ <pre class="prettyprint">
+ connection.start();
+ </pre>
+ <li>The message consumer receives the text message</li>
+ <pre class="prettyprint">
+ TextMessage textMessage = (TextMessage) consumer.receive(5000);
+ </pre>
+ <li>and we always clear up out JMS resources</li>
+ <pre class="prettyprint">
+ if (initialContext != null)
+ {
+ initialContext.close();
+ }
+ if (connection != null)
+ {
+ connection.close();
+ }
+ </pre>
+ </ol>
+ </body>
+</html>
\ No newline at end of file
Copied: trunk/examples/javaee/jca-remote/server/hornetq-configuration.xml (from rev 9253,
trunk/examples/javaee/jca-config/server/hornetq-configuration.xml)
===================================================================
--- trunk/examples/javaee/jca-remote/server/hornetq-configuration.xml
(rev 0)
+++ trunk/examples/javaee/jca-remote/server/hornetq-configuration.xml 2010-05-24 13:05:46
UTC (rev 9254)
@@ -0,0 +1,61 @@
+<!--
+ ~ 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">
+
+
<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>
Copied: trunk/examples/javaee/jca-remote/server/hornetq-jms.xml (from rev 9253,
trunk/examples/javaee/jca-config/server/hornetq-jms.xml)
===================================================================
--- trunk/examples/javaee/jca-remote/server/hornetq-jms.xml (rev
0)
+++ trunk/examples/javaee/jca-remote/server/hornetq-jms.xml 2010-05-24 13:05:46 UTC (rev
9254)
@@ -0,0 +1,20 @@
+<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
Copied: trunk/examples/javaee/jca-remote/server/jms-ds.xml (from rev 9253,
trunk/examples/javaee/jca-config/server2/jms-remote-ds.xml)
===================================================================
--- trunk/examples/javaee/jca-remote/server/jms-ds.xml (rev 0)
+++ trunk/examples/javaee/jca-remote/server/jms-ds.xml 2010-05-24 13:05:46 UTC (rev 9254)
@@ -0,0 +1,38 @@
+<?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.Topic</config-property>
+ <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>
+ </tx-connection-factory>
+
+
+</connection-factories>
Copied: trunk/examples/javaee/jca-remote/server/ra.xml (from rev 9253,
trunk/examples/javaee/jca-config/server2/ra.xml)
===================================================================
--- trunk/examples/javaee/jca-remote/server/ra.xml (rev 0)
+++ trunk/examples/javaee/jca-remote/server/ra.xml 2010-05-24 13:05:46 UTC (rev 9254)
@@ -0,0 +1,109 @@
+<?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>
+
<resourceadapter-class>org.hornetq.ra.HornetQResourceAdapter</resourceadapter-class>
+ <config-property>
+ <description>The transport type</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>
+ <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>
+ </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>
Added: trunk/examples/javaee/jca-remote/server0/client-jndi.properties
===================================================================
--- trunk/examples/javaee/jca-remote/server0/client-jndi.properties
(rev 0)
+++ trunk/examples/javaee/jca-remote/server0/client-jndi.properties 2010-05-24 13:05:46
UTC (rev 9254)
@@ -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
Copied: trunk/examples/javaee/jca-remote/server0/hornetq-beans.xml (from rev 9253,
trunk/examples/jms/queue/server0/hornetq-beans.xml)
===================================================================
--- trunk/examples/javaee/jca-remote/server0/hornetq-beans.xml
(rev 0)
+++ trunk/examples/javaee/jca-remote/server0/hornetq-beans.xml 2010-05-24 13:05:46 UTC
(rev 9254)
@@ -0,0 +1,72 @@
+<?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.
+ -->
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="Naming" class="org.jnp.server.NamingBeanImpl"/>
+
+ <!-- JNDI server. Disable this if you don't want JNDI -->
+ <bean name="JNDIServer" class="org.jnp.server.Main">
+ <property name="namingInfo">
+ <inject bean="Naming"/>
+ </property>
+ <property name="port">1199</property>
+ <property name="bindAddress">localhost</property>
+ <property name="rmiPort">1198</property>
+ <property name="rmiBindAddress">localhost</property>
+ </bean>
+
+ <!-- MBean server -->
+ <bean name="MBeanServer"
class="javax.management.MBeanServer">
+ <constructor factoryClass="java.lang.management.ManagementFactory"
+ factoryMethod="getPlatformMBeanServer"/>
+ </bean>
+
+ <!-- The core configuration -->
+ <bean name="Configuration"
class="org.hornetq.core.config.impl.FileConfiguration"/>
+
+ <!-- The security manager -->
+ <bean name="HornetQSecurityManager"
class="org.hornetq.spi.core.security.HornetQSecurityManagerImpl">
+ <start ignored="true"/>
+ <stop ignored="true"/>
+ </bean>
+
+ <!-- The core server -->
+ <bean name="HornetQServer"
class="org.hornetq.core.server.impl.HornetQServerImpl">
+ <constructor>
+ <parameter>
+ <inject bean="Configuration"/>
+ </parameter>
+ <parameter>
+ <inject bean="MBeanServer"/>
+ </parameter>
+ <parameter>
+ <inject bean="HornetQSecurityManager"/>
+ </parameter>
+ </constructor>
+ <start ignored="true"/>
+ <stop ignored="true"/>
+ </bean>
+
+ <!-- The JMS server -->
+ <bean name="JMSServerManager"
class="org.hornetq.jms.server.impl.JMSServerManagerImpl">
+ <constructor>
+ <parameter>
+ <inject bean="HornetQServer"/>
+ </parameter>
+ </constructor>
+ </bean>
+
+</deployment>
Copied: trunk/examples/javaee/jca-remote/server0/hornetq-configuration.xml (from rev 9253,
trunk/examples/jms/queue/server0/hornetq-configuration.xml)
===================================================================
--- trunk/examples/javaee/jca-remote/server0/hornetq-configuration.xml
(rev 0)
+++ trunk/examples/javaee/jca-remote/server0/hornetq-configuration.xml 2010-05-24 13:05:46
UTC (rev 9254)
@@ -0,0 +1,57 @@
+<!--
+ ~ 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">
+
+ <!-- Connectors -->
+
+ <connectors>
+ <connector name="netty-connector">
+
<factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
+ <param key="port"
value="${hornetq.remoting.netty.port:5446}"/>
+ </connector>
+ </connectors>
+
+ <!-- Acceptors -->
+ <acceptors>
+ <acceptor name="netty-acceptor">
+
<factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
+ <param key="port"
value="${hornetq.remoting.netty.port:5446}"/>
+ </acceptor>
+ </acceptors>
+
+ <!-- Other config -->
+
+ <security-settings>
+ <!--security for example queue-->
+ <security-setting match="jms.queue.mdbQueue">
+ <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.mdbReplyQueue">
+ <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>
Copied: trunk/examples/javaee/jca-remote/server0/hornetq-jms.xml (from rev 9253,
trunk/examples/jms/queue/server0/hornetq-jms.xml)
===================================================================
--- trunk/examples/javaee/jca-remote/server0/hornetq-jms.xml (rev
0)
+++ trunk/examples/javaee/jca-remote/server0/hornetq-jms.xml 2010-05-24 13:05:46 UTC (rev
9254)
@@ -0,0 +1,36 @@
+<!--
+ ~ 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>
+ </connection-factory>
+
+ <!--the queue used by the example-->
+ <queue name="mdbQueue">
+ <entry name="/queue/mdbQueue"/>
+ </queue>
+
+ <queue name="mdbReplyQueue">
+ <entry name="/queue/mdbReplyQueue"/>
+ </queue>
+
+</configuration>
Copied: trunk/examples/javaee/jca-remote/server0/hornetq-users.xml (from rev 9253,
trunk/examples/jms/queue/server0/hornetq-users.xml)
===================================================================
--- trunk/examples/javaee/jca-remote/server0/hornetq-users.xml
(rev 0)
+++ trunk/examples/javaee/jca-remote/server0/hornetq-users.xml 2010-05-24 13:05:46 UTC
(rev 9254)
@@ -0,0 +1,7 @@
+<configuration xmlns="urn:hornetq"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:hornetq /schema/hornetq-users.xsd">
+ <!-- the default user. this is used where username is null-->
+ <defaultuser name="guest" password="guest">
+ <role name="guest"/>
+ </defaultuser>
+</configuration>
\ No newline at end of file
Copied:
trunk/examples/javaee/jca-remote/src/org/hornetq/javaee/example/MDBRemoteServerClientExample.java
(from rev 9253,
trunk/examples/javaee/jca-config/src/org/hornetq/javaee/example/MDBRemoteClientExample.java)
===================================================================
---
trunk/examples/javaee/jca-remote/src/org/hornetq/javaee/example/MDBRemoteServerClientExample.java
(rev 0)
+++
trunk/examples/javaee/jca-remote/src/org/hornetq/javaee/example/MDBRemoteServerClientExample.java 2010-05-24
13:05:46 UTC (rev 9254)
@@ -0,0 +1,99 @@
+/*
+ * 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 org.hornetq.common.example.HornetQExample;
+
+import javax.jms.*;
+import javax.naming.InitialContext;
+
+/**
+ *
+ * MDB Remote & JCA Configuration Example.
+ *
+ * @author <a href="mailto:clebert.suconic@jboss.org">Clebert
Suconic</a>
+ */
+public class MDBRemoteServerClientExample extends HornetQExample
+{
+ public static void main(String[] args) throws Exception
+ {
+ new MDBRemoteServerClientExample().run(args);
+ }
+
+ @Override
+ public boolean runExample() throws Exception
+ {
+ InitialContext initialContext = null;
+ Connection connection = null;
+ try
+ {
+ System.out.println("Please start the Application Server by running
'./build.sh deploy' (build.bat on windows)");
+ System.in.read();
+
+ // Step 1. Create an initial context to perform the JNDI lookup.
+ initialContext = getContext(0);
+
+ // Step 2. Look up the MDB's queue
+ Queue queue = (Queue) initialContext.lookup("queue/mdbQueue");
+
+ // Step 3. Look up a Connection Factory
+ ConnectionFactory cf = (ConnectionFactory)
initialContext.lookup("ConnectionFactory");
+
+ //Step 4. Create a connection
+ connection = cf.createConnection();
+
+ //Step 5. Create a Session
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ // Step 6. Create a message producer to send the message
+ MessageProducer producer = session.createProducer(queue);
+
+ // Step 7. Create and send a message
+ producer.send(session.createTextMessage("a message"));
+
+ // Step 15. Look up the reply queue
+ Queue replyQueue = (Queue)
initialContext.lookup("queue/mdbReplyQueue");
+
+ // Step 16. Create a message consumer to receive the message
+ MessageConsumer consumer = session.createConsumer(replyQueue);
+
+ // Step 17. Start the connection so delivery starts
+ connection.start();
+
+ // Step 18. Receive the text message
+ TextMessage textMessage = (TextMessage) consumer.receive(5000);
+
+ System.out.println("Message received from reply queue. Message =
\"" + textMessage.getText() + "\"" );
+
+ System.out.println("stop the Application Server and press enter");
+
+ System.in.read();
+
+ return true;
+ }
+ finally
+ {
+ // Step 19. Be sure to close our JMS resources!
+ if (initialContext != null)
+ {
+ initialContext.close();
+ }
+ if (connection != null)
+ {
+ connection.close();
+ }
+ }
+ }
+}
\ No newline at end of file
Added:
trunk/examples/javaee/jca-remote/src/org/hornetq/javaee/example/server/MDBQueue.java
===================================================================
--- trunk/examples/javaee/jca-remote/src/org/hornetq/javaee/example/server/MDBQueue.java
(rev 0)
+++
trunk/examples/javaee/jca-remote/src/org/hornetq/javaee/example/server/MDBQueue.java 2010-05-24
13:05:46 UTC (rev 9254)
@@ -0,0 +1,87 @@
+/*
+ * 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.ActivationConfigProperty;
+import javax.ejb.MessageDriven;
+import javax.jms.*;
+
+/**
+ * @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
+ * Created May 24, 2010
+ */
+
+/**
+ * MDB that is connected to the remote queue.
+ * @author <a href="mailto:clebert.suconic@jboss.org">Clebert
Suconic</a>
+ */
+
+//Step 10. The message is received on the MDB, using a remote queue.
+@MessageDriven(name = "MDB_Queue",
+ activationConfig =
+ {
+ @ActivationConfigProperty(propertyName =
"destinationType", propertyValue = "javax.jms.Queue"),
+ @ActivationConfigProperty(propertyName = "destination",
propertyValue = "queue/mdbQueue"),
+ @ActivationConfigProperty(propertyName =
"acknowledgeMode", propertyValue = "Auto-acknowledge")
+ })
+(a)ResourceAdapter("hornetq-ra.rar")
+public class MDBQueue implements MessageListener
+{
+ /**
+ * Resource to be deployed by jms-remote-ds.xml
+ * */
+ @Resource(mappedName="java:RemoteJmsXA")
+ private ConnectionFactory connectionFactory;
+
+ public void onMessage(Message message)
+ {
+ try
+ {
+ // Step 8. Receive the text message
+ TextMessage tm = (TextMessage)message;
+
+ String text = tm.getText();
+
+ System.out.println("Step 11: (MDBQueue.java) Message received using the
remote adapter. Message = \"" + text + "\"" );
+
+ // Step 9. look up the reply queue
+ Queue destQueue = HornetQJMSClient.createQueue("mdbReplyQueue");
+
+ // Step 10. Create a connection
+ Connection connection = connectionFactory.createConnection();
+
+ // Step 11. Create a session
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ // Step 12. Create a message producer to send the message
+ MessageProducer producer = session.createProducer(destQueue);
+
+ System.out.println("sending a reply message");
+
+ // Step 13. Create and send a reply text message
+ producer.send(session.createTextMessage("A reply message"));
+
+ // Step 14. Return the connection back to the pool
+ connection.close();
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+}