JBoss hornetq SVN: r9254 - in trunk: examples/javaee and 12 other directories.
by do-not-reply@jboss.org
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")
+ })
+@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();
+ }
+ }
+}
15 years, 7 months
JBoss hornetq SVN: r9253 - trunk/src/main/org/hornetq/api/core/client.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2010-05-21 18:52:11 -0400 (Fri, 21 May 2010)
New Revision: 9253
Modified:
trunk/src/main/org/hornetq/api/core/client/ClientSessionFactory.java
Log:
just changing javadoc as pointed by an user on forums
Modified: trunk/src/main/org/hornetq/api/core/client/ClientSessionFactory.java
===================================================================
--- trunk/src/main/org/hornetq/api/core/client/ClientSessionFactory.java 2010-05-21 15:47:20 UTC (rev 9252)
+++ trunk/src/main/org/hornetq/api/core/client/ClientSessionFactory.java 2010-05-21 22:52:11 UTC (rev 9253)
@@ -467,7 +467,7 @@
/**
* Sets the acknowledgements batch size.
*
- * Value must be greater than 0.
+ * Value must be equal or greater than 0.
*
* @param ackBatchSize acknowledgements batch size
*/
15 years, 7 months
JBoss hornetq SVN: r9252 - in trunk: src/main/org/hornetq/ra and 1 other directory.
by do-not-reply@jboss.org
Author: ataylor
Date: 2010-05-21 11:47:20 -0400 (Fri, 21 May 2010)
New Revision: 9252
Modified:
trunk/examples/javaee/jca-config/server2/ra.xml
trunk/src/main/org/hornetq/ra/HornetQResourceAdapter.java
Log:
https://jira.jboss.org/browse/HORNETQ-391 - fixed using the correcxt transport params
Modified: trunk/examples/javaee/jca-config/server2/ra.xml
===================================================================
--- trunk/examples/javaee/jca-config/server2/ra.xml 2010-05-21 14:37:48 UTC (rev 9251)
+++ trunk/examples/javaee/jca-config/server2/ra.xml 2010-05-21 15:47:20 UTC (rev 9252)
@@ -45,14 +45,8 @@
<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>port=5445</config-property-value>
+ <config-property-value>host=127.0.0.1;port=5445</config-property-value>
</config-property>
- <config-property>
- <description>Use XA?</description>
- <config-property-name>UseXA</config-property-name>
- <config-property-type>java.lang.Boolean</config-property-type>
- <config-property-value>true</config-property-value>
- </config-property>
<outbound-resourceadapter>
<connection-definition>
Modified: trunk/src/main/org/hornetq/ra/HornetQResourceAdapter.java
===================================================================
--- trunk/src/main/org/hornetq/ra/HornetQResourceAdapter.java 2010-05-21 14:37:48 UTC (rev 9251)
+++ trunk/src/main/org/hornetq/ra/HornetQResourceAdapter.java 2010-05-21 15:47:20 UTC (rev 9252)
@@ -13,6 +13,7 @@
package org.hornetq.ra;
import java.io.Serializable;
+import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -1358,25 +1359,26 @@
: getDiscoveryAddress();
if (connectorClassName != null)
{
- Map<String, Object> connectionParams = overrideProperties.getParsedConnectionParameters() != null ? overrideProperties.getParsedConnectionParameters()
- : raProperties.getParsedConnectionParameters();
+ Map<String, Object> connectionParams =
+ overrideConnectionParameters(overrideProperties.getParsedConnectionParameters(),raProperties.getParsedConnectionParameters());
TransportConfiguration transportConf = new TransportConfiguration(connectorClassName, connectionParams);
String backUpCOnnectorClassname = overrideProperties.getBackupConnectorClassName() != null ? overrideProperties.getBackupConnectorClassName()
: getBackupConnectorClassName();
- Map<String, Object> backupConnectionParams = overrideProperties.getParsedBackupConnectionParameters() != null ? overrideProperties.getParsedBackupConnectionParameters()
- : getBackupConnectionParameters();
+ Map<String, Object> backupConnectionParams =
+ overrideConnectionParameters(overrideProperties.getParsedBackupConnectionParameters(),
+ getBackupConnectionParameters());
TransportConfiguration backup = backUpCOnnectorClassname == null ? null
: new TransportConfiguration(backUpCOnnectorClassname,
backupConnectionParams);
- cf = (HornetQConnectionFactory) HornetQJMSClient.createConnectionFactory(transportConf, backup);
+ cf = HornetQJMSClient.createConnectionFactory(transportConf, backup);
}
else if (discoveryAddress != null)
{
Integer discoveryPort = overrideProperties.getDiscoveryPort() != null ? overrideProperties.getDiscoveryPort()
: getDiscoveryPort();
- cf = (HornetQConnectionFactory) HornetQJMSClient.createConnectionFactory(discoveryAddress, discoveryPort);
+ cf = HornetQJMSClient.createConnectionFactory(discoveryAddress, discoveryPort);
}
else
{
@@ -1386,6 +1388,24 @@
return cf;
}
+ public Map<String, Object> overrideConnectionParameters(final Map<String, Object> connectionParams,
+ final Map<String, Object> overrideConnectionParams)
+ {
+ Map<String, Object> map = new HashMap<String, Object>();
+ if(connectionParams != null)
+ {
+ map.putAll(connectionParams);
+ }
+ if(overrideConnectionParams != null)
+ {
+ for (Map.Entry<String, Object> stringObjectEntry : overrideConnectionParams.entrySet())
+ {
+ map.put(stringObjectEntry.getKey(), stringObjectEntry.getValue());
+ }
+ }
+ return map;
+ }
+
private void setParams(final HornetQConnectionFactory cf,
final ConnectionFactoryProperties overrideProperties)
{
15 years, 7 months
JBoss hornetq SVN: r9251 - in branches/HnetQ_323_cn: tmp and 1 other directory.
by do-not-reply@jboss.org
Author: gaohoward
Date: 2010-05-21 10:37:48 -0400 (Fri, 21 May 2010)
New Revision: 9251
Added:
branches/HnetQ_323_cn/tmp/
branches/HnetQ_323_cn/tmp/applet-aop-new.tar.gz
branches/HnetQ_323_cn/tmp/jboss-4.2.3.GA.tar.gz
Log:
temp files for jbaop762 issue
Added: branches/HnetQ_323_cn/tmp/applet-aop-new.tar.gz
===================================================================
(Binary files differ)
Property changes on: branches/HnetQ_323_cn/tmp/applet-aop-new.tar.gz
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/HnetQ_323_cn/tmp/jboss-4.2.3.GA.tar.gz
===================================================================
(Binary files differ)
Property changes on: branches/HnetQ_323_cn/tmp/jboss-4.2.3.GA.tar.gz
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
15 years, 7 months
JBoss hornetq SVN: r9250 - trunk/src/main/org/hornetq/ra/inflow.
by do-not-reply@jboss.org
Author: jmesnil
Date: 2010-05-21 08:52:44 -0400 (Fri, 21 May 2010)
New Revision: 9250
Modified:
trunk/src/main/org/hornetq/ra/inflow/HornetQActivation.java
Log:
Resource Adapter Activation setup
* try to setup the HornetQActivation multiple times in case the JMS resources have not been deployed
by the AS before the MDB is activated
Modified: trunk/src/main/org/hornetq/ra/inflow/HornetQActivation.java
===================================================================
--- trunk/src/main/org/hornetq/ra/inflow/HornetQActivation.java 2010-05-20 12:48:35 UTC (rev 9249)
+++ trunk/src/main/org/hornetq/ra/inflow/HornetQActivation.java 2010-05-21 12:52:44 UTC (rev 9250)
@@ -102,6 +102,13 @@
private HornetQConnectionFactory factory;
+ // Whether we are in the failure recovery loop
+ private AtomicBoolean inFailure = new AtomicBoolean(false);
+
+ private final int setupAttempts = 5;
+
+ private final long setupInterval = 10 * 1000;
+
static
{
try
@@ -492,6 +499,56 @@
}
/**
+ * Handles any failure by trying to reconnect
+ *
+ * @param failure the reason for the failure
+ */
+ public void handleFailure(Throwable failure)
+ {
+ log.warn("Failure in HornetQ activation " + spec, failure);
+ int reconnectCount = 0;
+
+ // Only enter the failure loop once
+ if (inFailure.getAndSet(true))
+ return;
+ try
+ {
+ while (deliveryActive.get() && reconnectCount < setupAttempts)
+ {
+ teardown();
+
+ try
+ {
+ Thread.sleep(setupInterval);
+ }
+ catch (InterruptedException e)
+ {
+ log.debug("Interrupted trying to reconnect " + spec, e);
+ break;
+ }
+
+ log.info("Attempting to reconnect " + spec);
+ try
+ {
+ setup();
+ log.info("Reconnected with HornetQ");
+ break;
+ }
+ catch (Throwable t)
+ {
+ log.error("Unable to reconnect " + spec, t);
+ }
+ ++reconnectCount;
+ }
+ }
+ finally
+ {
+ // Leaving failure recovery loop
+ inFailure.set(false);
+ }
+ }
+
+ /**
* Handles the setup
*/
private class SetupActivation implements Work
@@ -504,7 +561,7 @@
}
catch (Throwable t)
{
- HornetQActivation.log.error("Unable to start activation ", t);
+ handleFailure(t);
}
}
15 years, 7 months
JBoss hornetq SVN: r9249 - in trunk: tests/src/org/hornetq/tests/integration and 1 other directories.
by do-not-reply@jboss.org
Author: ataylor
Date: 2010-05-20 08:48:35 -0400 (Thu, 20 May 2010)
New Revision: 9249
Added:
trunk/tests/src/org/hornetq/tests/integration/ra/
trunk/tests/src/org/hornetq/tests/integration/ra/HornetQMessageHandlerTest.java
Modified:
trunk/src/main/org/hornetq/ra/inflow/HornetQActivation.java
trunk/src/main/org/hornetq/ra/inflow/HornetQMessageHandler.java
Log:
https://jira.jboss.org/browse/HORNETQ-389 - fixed selector issue and added test
Modified: trunk/src/main/org/hornetq/ra/inflow/HornetQActivation.java
===================================================================
--- trunk/src/main/org/hornetq/ra/inflow/HornetQActivation.java 2010-05-19 15:32:37 UTC (rev 9248)
+++ trunk/src/main/org/hornetq/ra/inflow/HornetQActivation.java 2010-05-20 12:48:35 UTC (rev 9249)
@@ -458,6 +458,7 @@
if (Topic.class.getName().equals(spec.getDestinationType()))
{
destination = (HornetQDestination)HornetQJMSClient.createTopic(spec.getDestination());
+ isTopic = true;
}
else
{
Modified: trunk/src/main/org/hornetq/ra/inflow/HornetQMessageHandler.java
===================================================================
--- trunk/src/main/org/hornetq/ra/inflow/HornetQMessageHandler.java 2010-05-19 15:32:37 UTC (rev 9248)
+++ trunk/src/main/org/hornetq/ra/inflow/HornetQMessageHandler.java 2010-05-20 12:48:35 UTC (rev 9249)
@@ -124,11 +124,9 @@
SimpleString oldFilterString = subResponse.getFilterString();
boolean selectorChanged = selector == null && oldFilterString != null ||
- oldFilterString == null &&
- selector != null ||
- oldFilterString != null &&
- selector != null &&
- !oldFilterString.equals(selector);
+ oldFilterString == null && selector != null ||
+ (oldFilterString != null && selector != null &&
+ !oldFilterString.toString().equals(selector));
SimpleString oldTopicName = subResponse.getAddress();
Added: trunk/tests/src/org/hornetq/tests/integration/ra/HornetQMessageHandlerTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/ra/HornetQMessageHandlerTest.java (rev 0)
+++ trunk/tests/src/org/hornetq/tests/integration/ra/HornetQMessageHandlerTest.java 2010-05-20 12:48:35 UTC (rev 9249)
@@ -0,0 +1,288 @@
+/*
+ * 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.tests.integration.ra;
+
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.core.config.Configuration;
+import org.hornetq.core.server.HornetQServer;
+import org.hornetq.jms.client.HornetQMessage;
+import org.hornetq.ra.HornetQResourceAdapter;
+import org.hornetq.ra.inflow.HornetQActivationSpec;
+import org.hornetq.tests.util.ServiceTestBase;
+
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.resource.ResourceException;
+import javax.resource.spi.BootstrapContext;
+import javax.resource.spi.UnavailableException;
+import javax.resource.spi.XATerminator;
+import javax.resource.spi.endpoint.MessageEndpoint;
+import javax.resource.spi.endpoint.MessageEndpointFactory;
+import javax.resource.spi.work.*;
+import javax.transaction.xa.XAResource;
+import java.lang.reflect.Method;
+import java.util.Timer;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
+ * Created May 20, 2010
+ */
+public class HornetQMessageHandlerTest extends ServiceTestBase
+{
+ private Configuration configuration;
+
+ private HornetQServer server;
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ clearData();
+ configuration = createDefaultConfig();
+ configuration.setSecurityEnabled(false);
+ server = createServer(true, configuration);
+ server.start();
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ if (server != null)
+ {
+ try
+ {
+ server.stop();
+ server = null;
+ }
+ catch (Exception e)
+ {
+ // ignore
+ }
+ }
+ super.tearDown();
+ }
+
+ public void testSelectorChangedWithTopic() throws Exception
+ {
+ HornetQResourceAdapter qResourceAdapter = new HornetQResourceAdapter();
+ MyBootstrapContext ctx = new MyBootstrapContext();
+ qResourceAdapter.start(ctx);
+ HornetQActivationSpec spec = new HornetQActivationSpec();
+ spec.setResourceAdapter(qResourceAdapter);
+ spec.setUseJNDI(false);
+ spec.setDestinationType("javax.jms.Topic");
+ spec.setDestination("mdbTopic");
+ spec.setSubscriptionDurability("Durable");
+ spec.setSubscriptionName("durable-mdb");
+ spec.setClientID("id-1");
+ spec.setMessageSelector("foo='bar'");
+ qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY);
+ CountDownLatch latch = new CountDownLatch(1);
+ DummyMessageEndpoint endpoint = new DummyMessageEndpoint(latch);
+ DummyMessageEndpointFactory endpointFactory = new DummyMessageEndpointFactory(endpoint);
+ qResourceAdapter.endpointActivation(endpointFactory, spec);
+ ClientSession session = createFactory(false).createSession();
+ ClientProducer clientProducer = session.createProducer("jms.topic.mdbTopic");
+ ClientMessage message = session.createMessage(true);
+ message.getBodyBuffer().writeString("1");
+ message.putStringProperty("foo", "bar");
+ clientProducer.send(message);
+
+ latch.await(5, TimeUnit.SECONDS);
+
+ assertNotNull(endpoint.lastMessage);
+ assertEquals(endpoint.lastMessage.getCoreMessage().getBodyBuffer().readString(), "1");
+
+ qResourceAdapter.endpointDeactivation(endpointFactory, spec);
+
+ message = session.createMessage(true);
+ message.getBodyBuffer().writeString("2");
+ message.putStringProperty("foo", "bar");
+ clientProducer.send(message);
+
+ latch = new CountDownLatch(1);
+ endpoint = new DummyMessageEndpoint(latch);
+ //change the selector forcing the queue to be recreated
+ spec.setMessageSelector("foo='abar'");
+ endpointFactory = new DummyMessageEndpointFactory(endpoint);
+ qResourceAdapter.endpointActivation(endpointFactory, spec);
+ message = session.createMessage(true);
+ message.getBodyBuffer().writeString("3");
+ message.putStringProperty("foo", "abar");
+ clientProducer.send(message);
+ latch.await(5, TimeUnit.SECONDS);
+
+ assertNotNull(endpoint.lastMessage);
+ assertEquals(endpoint.lastMessage.getCoreMessage().getBodyBuffer().readString(), "3");
+ qResourceAdapter.endpointDeactivation(endpointFactory, spec);
+ }
+
+ public void testSelectorNotChangedWithTopic() throws Exception
+ {
+ HornetQResourceAdapter qResourceAdapter = new HornetQResourceAdapter();
+ MyBootstrapContext ctx = new MyBootstrapContext();
+ qResourceAdapter.start(ctx);
+ HornetQActivationSpec spec = new HornetQActivationSpec();
+ spec.setResourceAdapter(qResourceAdapter);
+ spec.setUseJNDI(false);
+ spec.setDestinationType("javax.jms.Topic");
+ spec.setDestination("mdbTopic");
+ spec.setSubscriptionDurability("Durable");
+ spec.setSubscriptionName("durable-mdb");
+ spec.setClientID("id-1");
+ spec.setMessageSelector("foo='bar'");
+ qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY);
+ CountDownLatch latch = new CountDownLatch(1);
+ DummyMessageEndpoint endpoint = new DummyMessageEndpoint(latch);
+ DummyMessageEndpointFactory endpointFactory = new DummyMessageEndpointFactory(endpoint);
+ qResourceAdapter.endpointActivation(endpointFactory, spec);
+ ClientSession session = createFactory(false).createSession();
+ ClientProducer clientProducer = session.createProducer("jms.topic.mdbTopic");
+ ClientMessage message = session.createMessage(true);
+ message.getBodyBuffer().writeString("1");
+ message.putStringProperty("foo", "bar");
+ clientProducer.send(message);
+
+ latch.await(5, TimeUnit.SECONDS);
+
+ assertNotNull(endpoint.lastMessage);
+ assertEquals(endpoint.lastMessage.getCoreMessage().getBodyBuffer().readString(), "1");
+
+ qResourceAdapter.endpointDeactivation(endpointFactory, spec);
+
+ message = session.createMessage(true);
+ message.getBodyBuffer().writeString("2");
+ message.putStringProperty("foo", "bar");
+ clientProducer.send(message);
+
+ latch = new CountDownLatch(1);
+ endpoint = new DummyMessageEndpoint(latch);
+ endpointFactory = new DummyMessageEndpointFactory(endpoint);
+ qResourceAdapter.endpointActivation(endpointFactory, spec);
+ latch.await(5, TimeUnit.SECONDS);
+
+ assertNotNull(endpoint.lastMessage);
+ assertEquals(endpoint.lastMessage.getCoreMessage().getBodyBuffer().readString(), "2");
+ qResourceAdapter.endpointDeactivation(endpointFactory, spec);
+
+ }
+
+ class DummyMessageEndpointFactory implements MessageEndpointFactory
+ {
+ private DummyMessageEndpoint endpoint;
+
+ public DummyMessageEndpointFactory(DummyMessageEndpoint endpoint)
+ {
+ this.endpoint = endpoint;
+ }
+
+ public MessageEndpoint createEndpoint(XAResource xaResource) throws UnavailableException
+ {
+ return endpoint;
+ }
+
+ public boolean isDeliveryTransacted(Method method) throws NoSuchMethodException
+ {
+ return false;
+ }
+ }
+
+ class DummyMessageEndpoint implements MessageEndpoint, MessageListener
+ {
+ public CountDownLatch latch;
+
+ private HornetQMessage lastMessage;
+
+ public DummyMessageEndpoint(CountDownLatch latch)
+ {
+ this.latch = latch;
+ }
+
+ public void beforeDelivery(Method method) throws NoSuchMethodException, ResourceException
+ {
+
+ }
+
+ public void afterDelivery() throws ResourceException
+ {
+ if(latch != null)
+ {
+ latch.countDown();
+ }
+ }
+
+ public void release()
+ {
+
+ }
+
+ public void onMessage(Message message)
+ {
+ lastMessage = (HornetQMessage) message;
+ }
+ }
+
+ class MyBootstrapContext implements BootstrapContext
+ {
+ WorkManager workManager = new DummyWorkManager();
+
+ public Timer createTimer() throws UnavailableException
+ {
+ return null;
+ }
+
+ public WorkManager getWorkManager()
+ {
+ return workManager;
+ }
+
+ public XATerminator getXATerminator()
+ {
+ return null;
+ }
+
+ class DummyWorkManager implements WorkManager
+ {
+ public void doWork(Work work) throws WorkException
+ {
+ }
+
+ public void doWork(Work work, long l, ExecutionContext executionContext, WorkListener workListener) throws WorkException
+ {
+ }
+
+ public long startWork(Work work) throws WorkException
+ {
+ return 0;
+ }
+
+ public long startWork(Work work, long l, ExecutionContext executionContext, WorkListener workListener) throws WorkException
+ {
+ return 0;
+ }
+
+ public void scheduleWork(Work work) throws WorkException
+ {
+ work.run();
+ }
+
+ public void scheduleWork(Work work, long l, ExecutionContext executionContext, WorkListener workListener) throws WorkException
+ {
+ }
+ }
+ }
+}
15 years, 7 months
JBoss hornetq SVN: r9248 - in trunk/examples/javaee: jms-bridge/server and 10 other directories.
by do-not-reply@jboss.org
Author: jmesnil
Date: 2010-05-19 11:32:37 -0400 (Wed, 19 May 2010)
New Revision: 9248
Removed:
trunk/examples/javaee/ejb-jms-transaction/server/hornetq-users.xml
trunk/examples/javaee/jms-bridge/server/hornetq-users.xml
trunk/examples/javaee/mdb-bmt/server/hornetq-users.xml
trunk/examples/javaee/mdb-cmt-setrollbackonly/server/hornetq-users.xml
trunk/examples/javaee/mdb-cmt-tx-local/server/hornetq-users.xml
trunk/examples/javaee/mdb-cmt-tx-not-supported/server/hornetq-users.xml
trunk/examples/javaee/mdb-cmt-tx-required/server/hornetq-users.xml
trunk/examples/javaee/mdb-message-selector/server/hornetq-users.xml
trunk/examples/javaee/mdb-tx-send/server/hornetq-users.xml
trunk/examples/javaee/servlet-ssl/server/hornetq-users.xml
trunk/examples/javaee/servlet-transport/server/hornetq-users.xml
trunk/examples/javaee/xarecovery/server/hornetq-users.xml
Log:
clean up Java EE examples
* removed hornetq-users.xml from javaee examples' server configuration as HornetQ delegates security
to the AS security manager when run inside the AS.
Deleted: trunk/examples/javaee/ejb-jms-transaction/server/hornetq-users.xml
===================================================================
--- trunk/examples/javaee/ejb-jms-transaction/server/hornetq-users.xml 2010-05-19 11:53:18 UTC (rev 9247)
+++ trunk/examples/javaee/ejb-jms-transaction/server/hornetq-users.xml 2010-05-19 15:32:37 UTC (rev 9248)
@@ -1,7 +0,0 @@
-<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
Deleted: trunk/examples/javaee/jms-bridge/server/hornetq-users.xml
===================================================================
--- trunk/examples/javaee/jms-bridge/server/hornetq-users.xml 2010-05-19 11:53:18 UTC (rev 9247)
+++ trunk/examples/javaee/jms-bridge/server/hornetq-users.xml 2010-05-19 15:32:37 UTC (rev 9248)
@@ -1,7 +0,0 @@
-<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
Deleted: trunk/examples/javaee/mdb-bmt/server/hornetq-users.xml
===================================================================
--- trunk/examples/javaee/mdb-bmt/server/hornetq-users.xml 2010-05-19 11:53:18 UTC (rev 9247)
+++ trunk/examples/javaee/mdb-bmt/server/hornetq-users.xml 2010-05-19 15:32:37 UTC (rev 9248)
@@ -1,7 +0,0 @@
-<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
Deleted: trunk/examples/javaee/mdb-cmt-setrollbackonly/server/hornetq-users.xml
===================================================================
--- trunk/examples/javaee/mdb-cmt-setrollbackonly/server/hornetq-users.xml 2010-05-19 11:53:18 UTC (rev 9247)
+++ trunk/examples/javaee/mdb-cmt-setrollbackonly/server/hornetq-users.xml 2010-05-19 15:32:37 UTC (rev 9248)
@@ -1,7 +0,0 @@
-<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
Deleted: trunk/examples/javaee/mdb-cmt-tx-local/server/hornetq-users.xml
===================================================================
--- trunk/examples/javaee/mdb-cmt-tx-local/server/hornetq-users.xml 2010-05-19 11:53:18 UTC (rev 9247)
+++ trunk/examples/javaee/mdb-cmt-tx-local/server/hornetq-users.xml 2010-05-19 15:32:37 UTC (rev 9248)
@@ -1,7 +0,0 @@
-<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
Deleted: trunk/examples/javaee/mdb-cmt-tx-not-supported/server/hornetq-users.xml
===================================================================
--- trunk/examples/javaee/mdb-cmt-tx-not-supported/server/hornetq-users.xml 2010-05-19 11:53:18 UTC (rev 9247)
+++ trunk/examples/javaee/mdb-cmt-tx-not-supported/server/hornetq-users.xml 2010-05-19 15:32:37 UTC (rev 9248)
@@ -1,7 +0,0 @@
-<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
Deleted: trunk/examples/javaee/mdb-cmt-tx-required/server/hornetq-users.xml
===================================================================
--- trunk/examples/javaee/mdb-cmt-tx-required/server/hornetq-users.xml 2010-05-19 11:53:18 UTC (rev 9247)
+++ trunk/examples/javaee/mdb-cmt-tx-required/server/hornetq-users.xml 2010-05-19 15:32:37 UTC (rev 9248)
@@ -1,7 +0,0 @@
-<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
Deleted: trunk/examples/javaee/mdb-message-selector/server/hornetq-users.xml
===================================================================
--- trunk/examples/javaee/mdb-message-selector/server/hornetq-users.xml 2010-05-19 11:53:18 UTC (rev 9247)
+++ trunk/examples/javaee/mdb-message-selector/server/hornetq-users.xml 2010-05-19 15:32:37 UTC (rev 9248)
@@ -1,7 +0,0 @@
-<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
Deleted: trunk/examples/javaee/mdb-tx-send/server/hornetq-users.xml
===================================================================
--- trunk/examples/javaee/mdb-tx-send/server/hornetq-users.xml 2010-05-19 11:53:18 UTC (rev 9247)
+++ trunk/examples/javaee/mdb-tx-send/server/hornetq-users.xml 2010-05-19 15:32:37 UTC (rev 9248)
@@ -1,7 +0,0 @@
-<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
Deleted: trunk/examples/javaee/servlet-ssl/server/hornetq-users.xml
===================================================================
--- trunk/examples/javaee/servlet-ssl/server/hornetq-users.xml 2010-05-19 11:53:18 UTC (rev 9247)
+++ trunk/examples/javaee/servlet-ssl/server/hornetq-users.xml 2010-05-19 15:32:37 UTC (rev 9248)
@@ -1,7 +0,0 @@
-<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
Deleted: trunk/examples/javaee/servlet-transport/server/hornetq-users.xml
===================================================================
--- trunk/examples/javaee/servlet-transport/server/hornetq-users.xml 2010-05-19 11:53:18 UTC (rev 9247)
+++ trunk/examples/javaee/servlet-transport/server/hornetq-users.xml 2010-05-19 15:32:37 UTC (rev 9248)
@@ -1,7 +0,0 @@
-<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
Deleted: trunk/examples/javaee/xarecovery/server/hornetq-users.xml
===================================================================
--- trunk/examples/javaee/xarecovery/server/hornetq-users.xml 2010-05-19 11:53:18 UTC (rev 9247)
+++ trunk/examples/javaee/xarecovery/server/hornetq-users.xml 2010-05-19 15:32:37 UTC (rev 9248)
@@ -1,7 +0,0 @@
-<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
15 years, 7 months
JBoss hornetq SVN: r9247 - in trunk/src: config/jboss-as-5/non-clustered and 3 other directories.
by do-not-reply@jboss.org
Author: jmesnil
Date: 2010-05-19 07:53:18 -0400 (Wed, 19 May 2010)
New Revision: 9247
Added:
trunk/src/main/org/hornetq/ra/HornetQRAService.java
Modified:
trunk/src/config/jboss-as-5/clustered/hornetq-jboss-beans.xml
trunk/src/config/jboss-as-5/non-clustered/hornetq-jboss-beans.xml
trunk/src/config/jboss-as-6/clustered/hornetq-jboss-beans.xml
trunk/src/config/jboss-as-6/non-clustered/hornetq-jboss-beans.xml
Log:
https://jira.jboss.org/browse/HORNETQ-339: JBoss AS won't shutdown when HornetQ Server and HornetQ RA are used on that same server
* added a HornetQRAService POJO depending on HornetQServer to ensure that HornetQ Resource Adapter is stopped before HornetQ server
(else, the RA's invm connections will retry to connect indefinitely and prevent the AS to shtudown properly)
Modified: trunk/src/config/jboss-as-5/clustered/hornetq-jboss-beans.xml
===================================================================
--- trunk/src/config/jboss-as-5/clustered/hornetq-jboss-beans.xml 2010-05-18 21:16:38 UTC (rev 9246)
+++ trunk/src/config/jboss-as-5/clustered/hornetq-jboss-beans.xml 2010-05-19 11:53:18 UTC (rev 9247)
@@ -45,5 +45,17 @@
</parameter>
</constructor>
</bean>
-
+
+ <!-- POJO which ensures HornetQ Resource Adapter is stopped before HornetQServer -->
+ <!-- -->
+ <!-- update the RA object name if you rename hornetq-ra.rar to jms-ra.rar -->
+ <bean name="HornetQRAService" class="org.hornetq.ra.HornetQRAService">
+ <constructor>
+ <parameter>
+ <inject bean="MBeanServer"/>
+ </parameter>
+ <parameter>jboss.jca:name='hornetq-ra.rar',service=RARDeployment</parameter>
+ </constructor>
+ <depends>HornetQServer</depends>
+ </bean>
</deployment>
Modified: trunk/src/config/jboss-as-5/non-clustered/hornetq-jboss-beans.xml
===================================================================
--- trunk/src/config/jboss-as-5/non-clustered/hornetq-jboss-beans.xml 2010-05-18 21:16:38 UTC (rev 9246)
+++ trunk/src/config/jboss-as-5/non-clustered/hornetq-jboss-beans.xml 2010-05-19 11:53:18 UTC (rev 9247)
@@ -45,5 +45,18 @@
</parameter>
</constructor>
</bean>
-
+
+ <!-- POJO which ensures HornetQ Resource Adapter is stopped before HornetQServer -->
+ <!-- -->
+ <!-- update the RA object name if you rename hornetq-ra.rar to jms-ra.rar -->
+ <bean name="HornetQRAService" class="org.hornetq.ra.HornetQRAService">
+ <constructor>
+ <parameter>
+ <inject bean="MBeanServer"/>
+ </parameter>
+ <parameter>jboss.jca:name='hornetq-ra.rar',service=RARDeployment</parameter>
+ </constructor>
+ <depends>HornetQServer</depends>
+ </bean>
+
</deployment>
Modified: trunk/src/config/jboss-as-6/clustered/hornetq-jboss-beans.xml
===================================================================
--- trunk/src/config/jboss-as-6/clustered/hornetq-jboss-beans.xml 2010-05-18 21:16:38 UTC (rev 9246)
+++ trunk/src/config/jboss-as-6/clustered/hornetq-jboss-beans.xml 2010-05-19 11:53:18 UTC (rev 9247)
@@ -48,4 +48,15 @@
</constructor>
</bean>
+ <!-- POJO which ensures HornetQ Resource Adapter is stopped before HornetQServer -->
+ <bean name="HornetQRAService" class="org.hornetq.ra.HornetQRAService">
+ <constructor>
+ <parameter>
+ <inject bean="MBeanServer"/>
+ </parameter>
+ <parameter>jboss.jca:name='jms-ra.rar',service=RARDeployment</parameter>
+ </constructor>
+ <depends>HornetQServer</depends>
+ </bean>
+
</deployment>
Modified: trunk/src/config/jboss-as-6/non-clustered/hornetq-jboss-beans.xml
===================================================================
--- trunk/src/config/jboss-as-6/non-clustered/hornetq-jboss-beans.xml 2010-05-18 21:16:38 UTC (rev 9246)
+++ trunk/src/config/jboss-as-6/non-clustered/hornetq-jboss-beans.xml 2010-05-19 11:53:18 UTC (rev 9247)
@@ -48,4 +48,14 @@
</constructor>
</bean>
+ <!-- POJO which ensures HornetQ Resource Adapter is stopped before HornetQServer -->
+ <bean name="HornetQRAService" class="org.hornetq.ra.HornetQRAService">
+ <constructor>
+ <parameter>
+ <inject bean="MBeanServer"/>
+ </parameter>
+ <parameter>jboss.jca:name='jms-ra.rar',service=RARDeployment</parameter>
+ </constructor>
+ <depends>HornetQServer</depends>
+ </bean>
</deployment>
Added: trunk/src/main/org/hornetq/ra/HornetQRAService.java
===================================================================
--- trunk/src/main/org/hornetq/ra/HornetQRAService.java (rev 0)
+++ trunk/src/main/org/hornetq/ra/HornetQRAService.java 2010-05-19 11:53:18 UTC (rev 9247)
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.ra;
+
+import java.util.Set;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectInstance;
+import javax.management.ObjectName;
+
+import org.hornetq.core.logging.Logger;
+
+/**
+ * A HornetQRAService ensures that HornetQ Resource Adapter will be stopped *before* the HornetQ server.
+ * https://jira.jboss.org/browse/HORNETQ-339
+ *
+ * @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a>
+ *
+ *
+ */
+public class HornetQRAService
+{
+ // Constants -----------------------------------------------------
+
+ private static final Logger log = Logger.getLogger(HornetQRAService.class);
+
+ // Attributes ----------------------------------------------------
+
+ private final MBeanServer mBeanServer;
+
+ private final String resourceAdapterObjectName;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ public HornetQRAService(final MBeanServer mBeanServer, final String resourceAdapterObjectName)
+ {
+ this.mBeanServer = mBeanServer;
+ this.resourceAdapterObjectName = resourceAdapterObjectName;
+ }
+
+ // Public --------------------------------------------------------
+
+ public void stop()
+ {
+ try
+ {
+ ObjectName objectName = new ObjectName(resourceAdapterObjectName);
+ Set<ObjectInstance> mbeanSet = mBeanServer.queryMBeans(objectName, null);
+
+ for (ObjectInstance mbean : mbeanSet)
+ {
+ String stateString = (String)mBeanServer.getAttribute(mbean.getObjectName(), "StateString");
+
+ if ("Started".equalsIgnoreCase(stateString) || "Starting".equalsIgnoreCase(stateString))
+ {
+ mBeanServer.invoke(mbean.getObjectName(), "stop", new Object[0], new String[0]);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ log.error("Unable to stop HornetQ resource adapter.", e);
+ }
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
15 years, 7 months
JBoss hornetq SVN: r9246 - in trunk/tests/src/org/hornetq/tests: util and 1 other directory.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2010-05-18 17:16:38 -0400 (Tue, 18 May 2010)
New Revision: 9246
Modified:
trunk/tests/src/org/hornetq/tests/unit/core/asyncio/AsynchronousFileTest.java
trunk/tests/src/org/hornetq/tests/util/UnitTestCase.java
Log:
Tweak on test to avoid one failure
Modified: trunk/tests/src/org/hornetq/tests/unit/core/asyncio/AsynchronousFileTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/unit/core/asyncio/AsynchronousFileTest.java 2010-05-18 17:09:09 UTC (rev 9245)
+++ trunk/tests/src/org/hornetq/tests/unit/core/asyncio/AsynchronousFileTest.java 2010-05-18 21:16:38 UTC (rev 9246)
@@ -105,48 +105,55 @@
public void testReleaseBuffers() throws Exception
{
AsynchronousFileImpl controller = new AsynchronousFileImpl(executor, pollerExecutor);
- controller.open(FILE_NAME, 10000);
- WeakReference<ByteBuffer> bufferCheck = new WeakReference<ByteBuffer>(controller.getHandler());
- controller.fill(0, 10, 1024, (byte)0);
-
- ByteBuffer write = AsynchronousFileImpl.newBuffer(1024);
-
- for (int i = 0; i < 1024; i++)
+ WeakReference<ByteBuffer> bufferCheck = null;
+ try
{
- write.put(UnitTestCase.getSamplebyte(i));
- }
-
- final CountDownLatch latch = new CountDownLatch(1);
-
- controller.write(0, 1024, write, new AIOCallback()
- {
-
- public void onError(final int errorCode, final String errorMessage)
+ controller.open(FILE_NAME, 10000);
+ bufferCheck = new WeakReference<ByteBuffer>(controller.getHandler());
+ controller.fill(0, 10, 1024, (byte)0);
+
+ ByteBuffer write = AsynchronousFileImpl.newBuffer(1024);
+
+ for (int i = 0; i < 1024; i++)
{
+ write.put(UnitTestCase.getSamplebyte(i));
}
-
- public void done()
+
+ final CountDownLatch latch = new CountDownLatch(1);
+
+ controller.write(0, 1024, write, new AIOCallback()
{
- latch.countDown();
- }
- });
+
+ public void onError(final int errorCode, final String errorMessage)
+ {
+ }
+
+ public void done()
+ {
+ latch.countDown();
+ }
+ });
+
+ Assert.assertTrue(latch.await(10, TimeUnit.SECONDS));
+
+ WeakReference<ByteBuffer> bufferCheck2 = new WeakReference<ByteBuffer>(write);
+
+ AsynchronousFileImpl.destroyBuffer(write);
+
+ write = null;
+
+ UnitTestCase.forceGC(bufferCheck2, 5000);
+
+ Assert.assertNull(bufferCheck2.get());
+ }
+ finally
+ {
+ controller.close();
+ }
- Assert.assertTrue(latch.await(10, TimeUnit.SECONDS));
-
- WeakReference<ByteBuffer> bufferCheck2 = new WeakReference<ByteBuffer>(write);
-
- AsynchronousFileImpl.destroyBuffer(write);
-
- write = null;
-
- UnitTestCase.forceGC();
-
- Assert.assertNull(bufferCheck2.get());
-
- controller.close();
controller = null;
- UnitTestCase.forceGC();
+ UnitTestCase.forceGC(bufferCheck, 5000);
Assert.assertNull(bufferCheck.get());
}
Modified: trunk/tests/src/org/hornetq/tests/util/UnitTestCase.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/util/UnitTestCase.java 2010-05-18 17:09:09 UTC (rev 9245)
+++ trunk/tests/src/org/hornetq/tests/util/UnitTestCase.java 2010-05-18 21:16:38 UTC (rev 9246)
@@ -140,6 +140,30 @@
}
}
+ public static void forceGC(WeakReference<?> ref, long timeout)
+ {
+ long waitUntil = System.currentTimeMillis() + timeout;
+ // A loop that will wait GC, using the minimal time as possible
+ while (ref.get() != null && System.currentTimeMillis() < waitUntil)
+ {
+ ArrayList<String> list = new ArrayList<String>();
+ for (int i = 0 ; i < 1000; i++)
+ {
+ list.add("Some string with garbage with concatenation " + i);
+ }
+ list.clear();
+ list = null;
+ System.gc();
+ try
+ {
+ Thread.sleep(500);
+ }
+ catch (InterruptedException e)
+ {
+ }
+ }
+ }
+
// verify if these weak references are released after a few GCs
public static void checkWeakReferences(final WeakReference<?>... references)
{
15 years, 7 months
JBoss hornetq SVN: r9245 - trunk/tests/src/org/hornetq/tests/integration/clientcrash.
by do-not-reply@jboss.org
Author: timfox
Date: 2010-05-18 13:09:09 -0400 (Tue, 18 May 2010)
New Revision: 9245
Added:
trunk/tests/src/org/hornetq/tests/integration/clientcrash/CrashClient2.java
Log:
missing file
Added: trunk/tests/src/org/hornetq/tests/integration/clientcrash/CrashClient2.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/clientcrash/CrashClient2.java (rev 0)
+++ trunk/tests/src/org/hornetq/tests/integration/clientcrash/CrashClient2.java 2010-05-18 17:09:09 UTC (rev 9245)
@@ -0,0 +1,104 @@
+/*
+ * 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.tests.integration.clientcrash;
+
+import java.util.Arrays;
+
+import org.hornetq.api.core.TransportConfiguration;
+import org.hornetq.api.core.client.ClientConsumer;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.HornetQClient;
+import org.hornetq.core.logging.Logger;
+
+/**
+ * Code to be run in an external VM, via main().
+ *
+ * @author <a href="mailto:ovidiu@feodorov.com">Ovidiu Feodorov</a>
+ * @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a>
+ *
+ * @version <tt>$Revision$</tt>
+ */
+public class CrashClient2
+{
+ // Constants ------------------------------------------------------------------------------------
+
+ private static final Logger log = Logger.getLogger(CrashClient2.class);
+
+ // Static ---------------------------------------------------------------------------------------
+
+ public static void main(final String[] args) throws Exception
+ {
+ try
+ {
+ log.debug("args = " + Arrays.asList(args));
+
+ ClientSessionFactory sf = HornetQClient.createClientSessionFactory(new TransportConfiguration("org.hornetq.core.remoting.impl.netty.NettyConnectorFactory"));
+
+ sf.setClientFailureCheckPeriod(ClientCrashTest.PING_PERIOD);
+ sf.setConnectionTTL(ClientCrashTest.CONNECTION_TTL);
+
+ ClientSession session = sf.createSession(true, true, 1000000);
+ ClientProducer producer = session.createProducer(ClientCrashTest.QUEUE);
+
+ ClientMessage message = session.createMessage(false);
+ message.getBodyBuffer().writeString(ClientCrashTest.MESSAGE_TEXT_FROM_CLIENT);
+
+ producer.send(message);
+
+ //Now consume the message, but don't let ack get to server
+
+ //Consume the message
+ ClientConsumer cons = session.createConsumer(ClientCrashTest.QUEUE);
+
+ session.start();
+
+ ClientMessage msg = cons.receive(10000);
+
+ if (msg == null)
+ {
+ log.error("Didn't receive msg");
+
+ System.exit(1);
+ }
+
+ // exit without closing the session properly
+ System.exit(9);
+ }
+ catch (Throwable t)
+ {
+ log.error(t.getMessage(), t);
+ System.exit(1);
+ }
+ }
+
+ // Attributes -----------------------------------------------------------------------------------
+
+ // Constructors ---------------------------------------------------------------------------------
+
+ // Command implementation -----------------------------------------------------------------------
+
+ // Public ---------------------------------------------------------------------------------------
+
+ // Package protected ----------------------------------------------------------------------------
+
+ // Protected ------------------------------------------------------------------------------------
+
+ // Private --------------------------------------------------------------------------------------
+
+ // Inner classes --------------------------------------------------------------------------------
+
+}
15 years, 7 months