[jboss-cvs] JBoss Messaging SVN: r6586 - in trunk: examples/javaee/mdb-remote and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Apr 27 17:29:21 EDT 2009
Author: clebert.suconic at jboss.com
Date: 2009-04-27 17:29:21 -0400 (Mon, 27 Apr 2009)
New Revision: 6586
Added:
trunk/examples/javaee/mdb-remote/server-config/alternate-ra.xml
trunk/examples/javaee/mdb-remote/server-config/jbm-jms.xml
trunk/examples/javaee/mdb-remote/server-config/jbm-queues.xml
trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/server/MDBQueueA.java
trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/server/MDBQueueB.java
Removed:
trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/server/MDBRemoteExample.java
Modified:
trunk/.classpath
trunk/examples/javaee/mdb-remote/build.xml
trunk/examples/javaee/mdb-remote/readme.html
trunk/examples/javaee/mdb-remote/server-config/jms-remote-ds.xml
trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/MDBRemoteClientExample.java
trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/server/StatelessSender.java
Log:
Changes on MDB-remote (JCA) example
Modified: trunk/.classpath
===================================================================
--- trunk/.classpath 2009-04-27 17:52:43 UTC (rev 6585)
+++ trunk/.classpath 2009-04-27 21:29:21 UTC (rev 6586)
@@ -71,7 +71,6 @@
<classpathentry kind="src" path="examples/javaee/hajndi/src"/>
<classpathentry kind="src" path="examples/javaee/jms-bridge/src"/>
<classpathentry kind="src" path="examples/javaee/mdb/src"/>
- <classpathentry kind="src" path="examples/javaee/mdb-remote/src"/>
<classpathentry kind="src" path="examples/javaee/servlet-transport/src"/>
<classpathentry kind="src" path="examples/javaee/xarecovery/src"/>
<classpathentry kind="lib" path="thirdparty/apache-log4j/lib/log4j.jar"/>
Modified: trunk/examples/javaee/mdb-remote/build.xml
===================================================================
--- trunk/examples/javaee/mdb-remote/build.xml 2009-04-27 17:52:43 UTC (rev 6585)
+++ trunk/examples/javaee/mdb-remote/build.xml 2009-04-27 21:29:21 UTC (rev 6586)
@@ -30,8 +30,20 @@
<import file="../common/build.xml"/>
<target name="deploy">
- <copy file="./server-config/jms-remote-ds.xml" todir="${jboss.home}/server/default-with-jbm2/deploy"/>
- <antcall target="do-deploy"></antcall>
+ <copy file="./server-config/jms-remote-ds.xml" todir="${jboss.home}/server/default-with-jbm2/deploy" overwrite="yes"/>
+ <copy file="./server-config/jbm-queues.xml" tofile="${jboss.home}/server/default-with-jbm2/deploy/messaging.sar/jbm-queues.xml" overwrite="yes"/>
+ <copy file="./server-config/jbm-jms.xml" tofile="${jboss.home}/server/default-with-jbm2/deploy/messaging.sar/jbm-jms.xml" overwrite="yes"/>
+ <copy file="./server-config/jbm-queues.xml" tofile="${jboss.home}/server/default-with-jbm2_2/deploy/messaging.sar/jbm-queues.xml" overwrite="yes"/>
+ <copy file="./server-config/jbm-jms.xml" tofile="${jboss.home}/server/default-with-jbm2_2/deploy/messaging.sar/jbm-jms.xml" overwrite="yes"/>
+
+ <copy todir="${jboss.home}/server/default-with-jbm2/deploy/example-jbm-ra.rar.tmp" overwrite="yes">
+ <fileset dir="${jboss.home}/server/default-with-jbm2/deploy/jms-ra.rar" includes="**/*" excludes="META-INF/ra.xml"/>
+ </copy>
+ <copy file="./server-config/alternate-ra.xml" tofile="${jboss.home}/server/default-with-jbm2/deploy/example-jbm-ra.rar.tmp/META-INF/ra.xml" overwrite="yes"/>
+ <!-- We need the deployment atomic. We only rename the file after the ra.xml was copied -->
+ <move file="${jboss.home}/server/default-with-jbm2/deploy/example-jbm-ra.rar.tmp" tofile="${jboss.home}/server/default-with-jbm2/deploy/example-jbm-ra.rar" overwrite="yes"/>
+ <sleep seconds="10"/>
+ <antcall target="do-deploy"></antcall>
</target>
Modified: trunk/examples/javaee/mdb-remote/readme.html
===================================================================
--- trunk/examples/javaee/mdb-remote/readme.html 2009-04-27 17:52:43 UTC (rev 6585)
+++ trunk/examples/javaee/mdb-remote/readme.html 2009-04-27 21:29:21 UTC (rev 6586)
@@ -5,11 +5,17 @@
</head>
<body>
<h1>Java EE JCA Configuration Example</h1>
- <p>This example shows you how to configure JBossMessagin's Resource Adapter</p>
- <p>A Resource Adapter is a way to connect any system provider to an application server.</p>
+ <p>This example is composed by two MDBs (MDBQueueA and MDBQueueB) and a StatlessSessionBean (StatelessSender).</p>
+ <p>The main class (MDBRemoteClientExample) will call a method on StatelessSender and send a Message to Queue B.<p>
+ <p>StatelessSender will send a message to Queue A.</p>
+ <p>StatelessSender is getting the connection out of the JavaConnectionArchitecture (JCA) ConnectionFactory, and sending a message to QueueA which will be received on MDBQueueA.</p>
+ <p>MDBQueueB is connected to a different JBoss Messaging resource-adapter, and it will receive the message sent by the main Class.</p>
+
+
+ <p>A Resource Adapter is a way to connect any system provider to an application server, and is integral part of the Java Connectors Architecture specification.</p>
<p>JBossMessaging provides its own adapter and this example will provide you a quick tutorial on how to configure some of the default properties, and how to change the default values on MDB Inbound Properties, or on ConnectionFactory Outbound Properties.</p>
<h2>MDB Properties</h2>
- <p>On MDBs, you could configure the adapter thorugh ActivactionConfigProperties on the MDB. Example:</p>
+ <p>You can configure the adapter through ActivactionConfigProperties on the MDB. Example:</p>
<pre>
<code>
@MessageDriven(name = "MessageMDBExample",
@@ -155,6 +161,18 @@
<pre><code>
sender.sendHello("Hello there MDB!");
</code></pre>
+
+
+ <li>Sending a message to Queue B, that will be received by MDBQueueB</li>
+ <pre><code>
+ ConnectionFactory cf = new JBossConnectionFactory(transportConfiguration);
+ Queue queue = new JBossQueue("B");
+ Connection conn = cf.createConnection("guest", "guest");
+ Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer prod = sess.createProducer(queue);
+ prod.send(sess.createTextMessage("Hello there MDB talking to another RAR!"));
+ conn.close();
+ </code></pre>
<li>On StatelessSender.java: Define the destination that will receive the message (instead of using JNDI to the remote server)</li>
@@ -167,55 +185,55 @@
Connection conn = connectionFactory.createConnection("guest", "guest");
</code></pre>
- <li>Send a message to a remote queue</li>
+ <li>Send a message to a QueueA on the remote server, which will be received by MDBQueueA</li>
<pre><code>
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer prod = sess.createProducer(destQueue);
prod.send(sess.createTextMessage(message));
</code></pre>
- <li>Close the queue. (Since this is a JCA connection, this close will save the connection to a connection pool)</li>
+ <li>Close the connection. (Since this is a JCA connection, this close will save the connection to a connection pool)</li>
<pre><code>
- sess.close();
+ conn.close();
</code></pre>
- <li>The message is received on the MDB, using the Remote Queue</li>
+ <li>The message is received on the MDBQueueA, using the Remote Queue</li>
-
-
<pre><code>
- at MessageDriven(name = "MessageMDBExample",
+ at MessageDriven(name = "MDB_QueueA",
activationConfig =
{
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
- @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/testQueue"),
+ @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/A"),
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
@ActivationConfigProperty(propertyName = "ConnectorClassName", propertyValue = "org.jboss.messaging.integration.transports.netty.NettyConnectorFactory"),
- @ActivationConfigProperty(propertyName = "ConnectionParameters", propertyValue = "jbm.remoting.netty.port=5545")
+ @ActivationConfigProperty(propertyName = "ConnectionParameters", propertyValue = "jbm.remoting.netty.port=5545") // Port on the second server
})
-public class MDBRemoteExample implements MessageListener
+public class MDBQueueA implements MessageListener
{
public void onMessage(Message message)
- {
- try
- {
- TextMessage tm = (TextMessage)message;
+ </code></pre>
+
- String text = tm.getText();
+ <li>Another message is received on MDBQueueB, using the Remote Queue. This MDB is using a different ResourceAdapter. Notice you didn't need to specify any Connection properties here, as you have different default values when using this resource-adapter (example-jbm-ra.rar).</li>
- System.out.println("message " + text + " received");
-
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-}
+ <pre><code>
+ at MessageDriven(name = "MDB_QueueB",
+ activationConfig =
+ {
+ @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
+ @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/B"),
+ @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge")
+ })
+ @ResourceAdapter("example-jbm-ra.rar")
+public class MDBQueueB implements MessageListener
+{
+
</code></pre>
+
</ol>
</body>
</html>
\ No newline at end of file
Added: trunk/examples/javaee/mdb-remote/server-config/alternate-ra.xml
===================================================================
--- trunk/examples/javaee/mdb-remote/server-config/alternate-ra.xml (rev 0)
+++ trunk/examples/javaee/mdb-remote/server-config/alternate-ra.xml 2009-04-27 21:29:21 UTC (rev 6586)
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- 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>JBoss Messaging 2.0 Resource Adapter Alternate Configuration</description>
+ <display-name>JBoss Messaging 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>
+ JBoss, Home of Professional Open Source.
+ Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ as indicated by the @author tags. See the copyright.txt file in the
+ distribution for a full listing of individual contributors.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ </description>
+ <license-required>true</license-required>
+ </license>
+
+ <resourceadapter>
+ <resourceadapter-class>org.jboss.messaging.ra.JBMResourceAdapter</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.jboss.messaging.integration.transports.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>jbm.remoting.netty.port=5545</config-property-value>
+ </config-property>
+ <config-property>
+ <description>Use XA methods to obtain connections?</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>
+ <config-property>
+ <description>The user name used to login to the JMS server</description>
+ <config-property-name>UserName</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value></config-property-value>
+ </config-property>
+ <config-property>
+ <description>The password used to login to the JMS server</description>
+ <config-property-name>Password</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value></config-property-value>
+ </config-property>
+
+ <outbound-resourceadapter>
+ <connection-definition>
+ <managedconnectionfactory-class>org.jboss.messaging.ra.JBMManagedConnectionFactory</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.jboss.messaging.ra.JBMConnectionFactory</connectionfactory-interface>
+ <connectionfactory-impl-class>org.jboss.messaging.ra.JBMConnectionFactoryImpl</connectionfactory-impl-class>
+ <connection-interface>javax.jms.Session</connection-interface>
+ <connection-impl-class>org.jboss.messaging.ra.JBMSession</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.jboss.messaging.ra.inflow.JBMActivationSpec</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/mdb-remote/server-config/jbm-jms.xml
===================================================================
--- trunk/examples/javaee/mdb-remote/server-config/jbm-jms.xml (rev 0)
+++ trunk/examples/javaee/mdb-remote/server-config/jbm-jms.xml 2009-04-27 21:29:21 UTC (rev 6586)
@@ -0,0 +1,194 @@
+<deployment xmlns="urn:jboss:messaging"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:messaging ../schemas/jbm-jms.xsd ">
+
+ <connection-factory name="testConnectionFactory">
+ <connector-ref connector-name="netty-connector"/>
+ <entries>
+ <entry name="testConnectionFactory"/>
+ </entries>
+ </connection-factory>
+
+ <connection-factory name="ConnectionFactory">
+ <connector-ref connector-name="netty-connector"/>
+ <entries>
+ <entry name="ConnectionFactory"/>
+ <entry name="/ConnectionFactory"/>
+ <entry name="/XAConnectionFactory"/>
+ <entry name="java:/ConnectionFactory"/>
+ <entry name="java:/XAConnectionFactory"/>
+ </entries>
+ </connection-factory>
+
+ <connection-factory name="ServerAckConnectionFactory">
+ <connector-ref connector-name="netty-connector"/>
+ <entries>
+ <entry name="ServerAckConnectionFactory"/>
+ <entry name="/ServerAckConnectionFactory"/>
+ <entry name="/ServerAckXAConnectionFactory"/>
+ <entry name="java:/ServerAckConnectionFactory"/>
+ <entry name="java:/ServerAckXAConnectionFactory"/>
+ </entries>
+ <pre-acknowledge>true</pre-acknowledge>
+ </connection-factory>
+
+ <connection-factory name="ClusteredConnectionFactory">
+ <connector-ref connector-name="netty-connector" backup-connector-name="netty-backup"/>
+ <entries>
+ <entry name="/ClusteredConnectionFactory"/>
+ <entry name="/ClusteredXAConnectionFactory"/>
+ <entry name="java:/ClusteredConnectionFactory"/>
+ <entry name="java:/ClusteredXAConnectionFactory"/>
+ </entries>
+ </connection-factory>
+
+ <connection-factory name="ClusteredConnectionFactoryWithDiscovery">
+ <discovery-group-ref discovery-group-name="dg-group1"/>
+ <entries>
+ <entry name="/ClusteredConnectionFactory"/>
+ <entry name="/ClusteredXAConnectionFactory"/>
+ <entry name="java:/ClusteredConnectionFactory"/>
+ <entry name="java:/ClusteredXAConnectionFactory"/>
+ </entries>
+ </connection-factory>
+
+ <connection-factory name="MyExampleConnectionFactory">
+ <connector-ref connector-name="netty-connector"/>
+ <entries>
+ <entry name="/MyExampleConnectionFactory"/>
+ <entry name="/acme/MyExampleConnectionFactoryDupe"/>
+ <entry name="java:/xyz/CF1"/>
+ <entry name="java:/connectionfactories/acme/connection_factory"/>
+ </entries>
+ <ping-period>5000</ping-period>
+ <call-timeout>30000</call-timeout>
+ <!-- This is the window size in bytes to use when using consumer window based flow control -->
+ <consumer-window-size>1048576</consumer-window-size>
+ <!-- This is the maximum producer send rate that will be applied when using rate based consumer flow control -->
+ <consumer-max-rate>5000</consumer-max-rate>
+ <!-- This is the send window size in bytes -->
+ <producer-window-size>1048576</producer-window-size>
+ <!-- This is the maximum producer send rate that will be applied when using rate based producer flow control -->
+ <producer-max-rate>100</producer-max-rate>
+ <!-- When using this ConnectionFactory, messages beyond this limit are considered largeMessages and will be sent using smaller packets -->
+ <min-large-message-size>10240</min-large-message-size>
+ <!-- You can specify the default Client ID to use for connections created using this factory -->
+ <client-id>MyClientID</client-id>
+ <!-- The batch size in bytes to use when using the DUPS_OK_ACKNOWLEDGE acknowledgement mode -->
+ <dups-ok-batch-size>1048576</dups-ok-batch-size>
+ <!-- The batch size in bytes to use when using transactional sessions -->
+ <transaction-batch-size>1048576</transaction-batch-size>
+ <!--Whether or not we use a blocking call when acknowledging a message-->
+ <block-on-acknowledge>false</block-on-acknowledge>
+ <!--Whether we send non persistent messages synchronously-->
+ <send-np-messages-synchronously>true</send-np-messages-synchronously>
+ <!--Whether we send persistent messages synchronously-->
+ <send-p-messages-synchronously>true</send-p-messages-synchronously>
+ <!--If true, any connections will automatically set a unique group id (per producer) on every message sent-->
+ <auto-group-id>true</auto-group-id>
+ <!--if true then the server will pre ack any message before delivery to a consumer-->
+ <pre-acknowledge>false</pre-acknowledge>
+ </connection-factory>
+
+ <connection-factory name="TestInVMConnectionFactory">
+ <connector-ref connector-name="in-vm"/>
+ <entries>
+ <entry name="/TestInVMConnectionFactory"/>
+ </entries>
+ </connection-factory>
+
+ <connection-factory name="TestSSLConnectionFactory">
+ <connector-ref connector-name="netty-ssl"/>
+ <entries>
+ <entry name="/TestSSLConnectionFactory"/>
+ </entries>
+ </connection-factory>
+
+ <connection-factory name="TestHttpConnectionFactory">
+ <connector-ref connector-name="netty-http"/>
+ <entries>
+ <entry name="/TestHttpConnectionFactory"/>
+ </entries>
+ </connection-factory>
+
+ <connection-factory name="TestServletConnectionFactory">
+ <connector-ref connector-name="netty-servlet"/>
+ <entries>
+ <entry name="/TestServletConnectionFactory"/>
+ </entries>
+ </connection-factory>
+
+ <queue name="MyQueue">
+ <entry name="MyQueue"/>
+ </queue>
+ <queue name="DLQ">
+ <entry name="/queue/DLQ"/>
+ </queue>
+ <queue name="ExpiryQueue">
+ <entry name="/queue/ExpiryQueue"/>
+ </queue>
+ <topic name="testTopic">
+ <entry name="/topic/testTopic"/>
+ </topic>
+ <topic name="topic.A">
+ <entry name="/topic/topicA"/>
+ </topic>
+ <topic name="topic.B">
+ <entry name="/topic/topicB"/>
+ </topic>
+ <topic name="securedTopic">
+ <entry name="/topic/securedTopic"/>
+ </topic>
+ <topic name="testDurableTopic">
+ <entry name="/topic/testDurableTopic"/>
+ </topic>
+ <queue name="testQueue">
+ <entry name="/queue/testQueue"/>
+ </queue>
+ <queue name="testGroupQueue">
+ <entry name="/queue/testGroupQueue"/>
+ </queue>
+ <queue name="testPerfQueue">
+ <entry name="/queue/testPerfQueue"/>
+ </queue>
+ <queue name="A">
+ <entry name="/queue/A"/>
+ </queue>
+ <queue name="B">
+ <entry name="/queue/B"/>
+ </queue>
+ <queue name="C">
+ <entry name="/queue/C"/>
+ </queue>
+ <queue name="D">
+ <entry name="/queue/D"/>
+ </queue>
+ <queue name="ex">
+ <entry name="/queue/ex"/>
+ </queue>
+ <queue name="PrivateDLQ">
+ <entry name="/queue/PrivateDLQ"/>
+ </queue>
+ <queue name="PrivateExpiryQueue">
+ <entry name="/queue/PrivateExpiryQueue"/>
+ </queue>
+ <queue name="QueueWithOwnDLQAndExpiryQueue">
+ <entry name="/queue/QueueWithOwnDLQAndExpiryQueue"/>
+ </queue>
+ <topic name="TopicWithOwnDLQAndExpiryQueue">
+ <entry name="/topic/QueueWithOwnDLQAndExpiryQueue"/>
+ </topic>
+ <queue name="QueueWithOwnRedeliveryDelay">
+ <entry name="/queue/QueueWithOwnRedeliveryDelay"/>
+ </queue>
+ <topic name="TopicWithOwnRedeliveryDelay">
+ <entry name="/topic/TopicWithOwnRedeliveryDelay"/>
+ </topic>
+ <queue name="testDistributedQueue">
+ <entry name="/queue/testDistributedQueue"/>
+ </queue>
+ <topic name="testDistributedTopic">
+ <entry name="/topic/testDistributedTopic"/>
+ </topic>
+
+</deployment>
\ No newline at end of file
Added: trunk/examples/javaee/mdb-remote/server-config/jbm-queues.xml
===================================================================
--- trunk/examples/javaee/mdb-remote/server-config/jbm-queues.xml (rev 0)
+++ trunk/examples/javaee/mdb-remote/server-config/jbm-queues.xml 2009-04-27 21:29:21 UTC (rev 6586)
@@ -0,0 +1,137 @@
+<settings xmlns="urn:jboss:messaging"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:messaging ../schemas/jbm-queues.xsd ">
+
+ <!-- manangement address -->
+ <security match="jbm.management">
+ <!-- only the admin role can interact with the management address -->
+ <permission type="consume" roles="admin"/>
+ <permission type="send" roles="admin"/>
+ <permission type="manage" roles="admin"/>
+ </security>
+
+ <security match="jms.topic.testTopic">
+ <permission type="createDurableQueue" roles="durpublisher"/>
+ <permission type="deleteDurableQueue" roles="durpublisher"/>
+ <permission type="consume" roles="guest,publisher,durpublisher"/>
+ <permission type="send" roles="guest,publisher,durpublisher"/>
+ </security>
+
+ <security match="jms.topic.securedTopic">
+ <permission type="send" roles="publisher"/>
+ <permission type="consume" roles="publisher"/>
+ </security>
+
+ <security match="jms.topic.testDurableTopic">
+ <permission type="createDurableQueue" roles="durpublisher"/>
+ <permission type="deleteDurableQueue" roles="durpublisher"/>
+ <permission type="consume" roles="guest,publisher,durpublisher"/>
+ <permission type="send" roles="guest,publisher,durpublisher"/>
+ </security>
+
+ <security match="jms.queue.testQueue">
+ <permission type="consume" roles="guest,publisher"/>
+ <permission type="send" roles="guest,publisher"/>
+ </security>
+
+ <security match="jms.queue.NoSuchQueue">
+ <permission type="consume" roles="guest,publisher"/>
+ <permission type="send" roles="guest,publisher"/>
+ </security>
+
+ <security match="jms.topic.NoSuchTopic">
+ <permission type="consume" roles="guest,publisher"/>
+ <permission type="send" roles="guest,publisher"/>
+ </security>
+
+ <security match="jms.tempqueue.#">
+ <permission type="createTempQueue" roles="guest,def"/>
+ <permission type="deleteTempQueue" roles="guest,def"/>
+ <permission type="consume" roles="guest,def"/>
+ <permission type="send" roles="guest,def"/>
+ </security>
+
+ <security match="jms.temptopic.#">
+ <permission type="createTempQueue" roles="guest,def"/>
+ <permission type="deleteTempQueue" roles="guest,def"/>
+ <permission type="consume" roles="guest,def"/>
+ <permission type="send" roles="guest,def"/>
+ </security>
+
+ <!--this will catch any word i.e. jms.queue.anything-->
+ <!--<security match="jms.queue.#">
+ <permission type="consume" roles="guest,publisher"/>
+ <permission type="send" roles="guest,publisher"/>
+ </security>-->
+
+ <!--this will catch any word i.e. jms.queue.anything-->
+ <!--<security match="jms.topic.#">
+ <permission type="consume" roles="guest,publisher"/>
+ <permission type="send" roles="guest,publisher"/>
+ </security>-->
+
+ <!--default security to catch all-->
+ <security match="#">
+ <permission type="createDurableQueue" roles="guest,def"/>
+ <permission type="deleteDurableQueue" roles="guest,def"/>
+ <permission type="createTempQueue" roles="guest,def"/>
+ <permission type="deleteTempQueue" roles="guest,def"/>
+ <permission type="consume" roles="guest,def"/>
+ <permission type="send" roles="guest,def"/>
+ </security>
+
+ <address-settings match="jms.queue.QueueWithOwnDLQAndExpiryQueue">
+ <dead-letter-address>jms.queue.PrivateDLQ</dead-letter-address>
+ <expiry-address>jms.queue.PrivateExpiryQueue</expiry-address>
+ </address-settings>
+
+ <address-settings match="jms.topic.TopicWithOwnDLQAndExpiryQueue">
+ <dead-letter-address>jms.queue.PrivateDLQ</dead-letter-address>
+ <expiry-address>jms.queue.PrivateExpiryQueue</expiry-address>
+ </address-settings>
+
+ <address-settings match="jms.queue.QueueWithOwnRedeliveryDelay">
+ <redelivery-delay>5000</redelivery-delay>
+ </address-settings>
+
+ <address-settings match="jms.topic.TopicWithOwnRedeliveryDelay">
+ <redelivery-delay>5000</redelivery-delay>
+ </address-settings>
+
+ <address-settings match="jms.queue.testDistributedQueue">
+ <clustered>true</clustered>
+ </address-settings>
+
+ <address-settings match="jms.topic.testDistributedTopic">
+ <clustered>true</clustered>
+ </address-settings>
+
+ <address-settings match="jms.queue.testPerfQueue">
+ <clustered>false</clustered>
+ </address-settings>
+
+ <address-settings match="jms.queue.MyQueue">
+ <max-size-bytes>-1</max-size-bytes>
+ <page-size-bytes>10485760</page-size-bytes>
+ <drop-messages-when-full>false</drop-messages-when-full>
+ </address-settings>
+
+ <address-settings match="jms.queue.testGroupQueue">
+ <max-size-bytes>-1</max-size-bytes>
+ <page-size-bytes>10485760</page-size-bytes>
+ <drop-messages-when-full>false</drop-messages-when-full>
+ <distribution-policy-class>org.jboss.messaging.core.server.impl.GroupingRoundRobinDistributor</distribution-policy-class>
+ </address-settings>
+
+ <!--default for catch all-->
+ <address-settings match="#">
+ <clustered>false</clustered>
+ <dead-letter-address>jms.queue.DLQ</dead-letter-address>
+ <expiry-address>jms.queue.ExpiryQueue</expiry-address>
+ <redelivery-delay>0</redelivery-delay>
+ <max-size-bytes>-1</max-size-bytes>
+ <page-size-bytes>10485760</page-size-bytes>
+ <distribution-policy-class>org.jboss.messaging.core.server.impl.RoundRobinDistributor</distribution-policy-class>
+ <message-counter-history-day-limit>10</message-counter-history-day-limit>
+ </address-settings>
+</settings>
Modified: trunk/examples/javaee/mdb-remote/server-config/jms-remote-ds.xml
===================================================================
--- trunk/examples/javaee/mdb-remote/server-config/jms-remote-ds.xml 2009-04-27 17:52:43 UTC (rev 6585)
+++ trunk/examples/javaee/mdb-remote/server-config/jms-remote-ds.xml 2009-04-27 21:29:21 UTC (rev 6586)
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- This file will be deployed by the target deploy on build.xml -->
<connection-factories>
Modified: trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/MDBRemoteClientExample.java
===================================================================
--- trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/MDBRemoteClientExample.java 2009-04-27 17:52:43 UTC (rev 6585)
+++ trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/MDBRemoteClientExample.java 2009-04-27 21:29:21 UTC (rev 6586)
@@ -21,10 +21,21 @@
*/
package org.jboss.javaee.example;
-import javax.jms.Connection;
+import static org.jboss.messaging.integration.transports.netty.TransportConstants.PORT_PROP_NAME;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.jms.*;
+import javax.jms.ConnectionFactory;
+import javax.jms.Queue;
import javax.naming.InitialContext;
import org.jboss.javaee.example.server.StatelessSenderService;
+import org.jboss.messaging.core.config.TransportConfiguration;
+import org.jboss.messaging.integration.transports.netty.NettyConnectorFactory;
+import org.jboss.messaging.jms.JBossQueue;
+import org.jboss.messaging.jms.client.JBossConnectionFactory;
/**
*
@@ -46,9 +57,35 @@
//Step 2. Getting a reference to the Stateless Bean
StatelessSenderService sender = (StatelessSenderService)initialContext.lookup("mdb-example/StatelessSender/remote");
- //Step 3. Calling the Stateless Bean
+ //Step 3. Calling a Stateless Session Bean. You will have more steps on the SessionBean
sender.sendHello("Hello there MDB!");
+
+ System.out.println("Step 3: Invoking the Stateless Bean");
+
+
+ Map<String, Object> connectionParams = new HashMap<String, Object>();
+ connectionParams.put(PORT_PROP_NAME, 5545);
+
+ TransportConfiguration transportConfiguration = new TransportConfiguration(NettyConnectorFactory.class.getName(),
+ connectionParams);
+
+ // Step 4. Sending a message to another
+ ConnectionFactory cf = new JBossConnectionFactory(transportConfiguration);
+ Queue queue = new JBossQueue("B");
+ Connection conn = cf.createConnection("guest", "guest");
+ Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer prod = sess.createProducer(queue);
+ prod.send(sess.createTextMessage("Hello there MDB talking to another RAR!"));
+ conn.close();
+
+
+ System.out.println("Step 4: Sent a message to QueueB.");
+
+
+ System.out.println("Follow other steps on the application server's consoles now.");
+
+
initialContext.close();
}
finally
Copied: trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/server/MDBQueueA.java (from rev 6585, trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/server/MDBRemoteExample.java)
===================================================================
--- trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/server/MDBQueueA.java (rev 0)
+++ trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/server/MDBQueueA.java 2009-04-27 21:29:21 UTC (rev 6586)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.javaee.example.server;
+
+import javax.ejb.ActivationConfigProperty;
+import javax.ejb.MessageDriven;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.TextMessage;
+
+/**
+ * MDB that is connected to the remote queue.
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ */
+
+//Step 9. The message is received on the MDB, using a remote queue.
+ at MessageDriven(name = "MDB_QueueA",
+ activationConfig =
+ {
+ @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
+ @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/A"),
+ @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
+ @ActivationConfigProperty(propertyName = "ConnectorClassName", propertyValue = "org.jboss.messaging.integration.transports.netty.NettyConnectorFactory"),
+ @ActivationConfigProperty(propertyName = "ConnectionParameters", propertyValue = "jbm.remoting.netty.port=5545") // Port on the second server
+ })
+public class MDBQueueA implements MessageListener
+{
+ public void onMessage(Message message)
+ {
+ try
+ {
+ TextMessage tm = (TextMessage)message;
+
+ String text = tm.getText();
+
+ System.out.println("Step 9: (MDBQueueA.java) Message received using the default adapter. Message = \"" + text + "\"" );
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+}
Added: trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/server/MDBQueueB.java
===================================================================
--- trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/server/MDBQueueB.java (rev 0)
+++ trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/server/MDBQueueB.java 2009-04-27 21:29:21 UTC (rev 6586)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.javaee.example.server;
+
+import javax.ejb.ActivationConfigProperty;
+import javax.ejb.MessageDriven;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.TextMessage;
+
+import org.jboss.ejb3.annotation.ResourceAdapter;
+
+
+/**
+ * MDB that is connected to the remote queue, using an alternate resource-adapter
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ */
+
+//Step 10. The message is received on the MDB, using a remote queue and a different ResourceAdapter
+ at MessageDriven(name = "MDB_QueueB",
+ activationConfig =
+ {
+ @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
+ @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/B"),
+ @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge")
+ })
+ @ResourceAdapter("example-jbm-ra.rar")
+
+public class MDBQueueB implements MessageListener
+{
+ public void onMessage(Message message)
+ {
+ try
+ {
+ TextMessage tm = (TextMessage)message;
+
+ String text = tm.getText();
+
+
+ System.out.println("Step 10: (MDBQueueB.java) Message received using the default adapter. Message = \"" + text + "\"" );
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+}
Deleted: trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/server/MDBRemoteExample.java
===================================================================
--- trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/server/MDBRemoteExample.java 2009-04-27 17:52:43 UTC (rev 6585)
+++ trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/server/MDBRemoteExample.java 2009-04-27 21:29:21 UTC (rev 6586)
@@ -1,63 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.javaee.example.server;
-
-import javax.ejb.ActivationConfigProperty;
-import javax.ejb.MessageDriven;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.TextMessage;
-
-/**
- * MDB that is connected to the remote queue.
- * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- */
-
-//Step 8. The message is received on the MDB, using a remote queue.
- at MessageDriven(name = "MessageMDBExample",
- activationConfig =
- {
- @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
- @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/A"),
- @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
- @ActivationConfigProperty(propertyName = "ConnectorClassName", propertyValue = "org.jboss.messaging.integration.transports.netty.NettyConnectorFactory"),
- @ActivationConfigProperty(propertyName = "ConnectionParameters", propertyValue = "jbm.remoting.netty.port=5545") // Port on the second server
- })
-public class MDBRemoteExample implements MessageListener
-{
- public void onMessage(Message message)
- {
- try
- {
- TextMessage tm = (TextMessage)message;
-
- String text = tm.getText();
-
- System.out.println("message " + text + " received");
-
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-}
Modified: trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/server/StatelessSender.java
===================================================================
--- trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/server/StatelessSender.java 2009-04-27 17:52:43 UTC (rev 6585)
+++ trunk/examples/javaee/mdb-remote/src/org/jboss/javaee/example/server/StatelessSender.java 2009-04-27 21:29:21 UTC (rev 6586)
@@ -26,10 +26,12 @@
import javax.annotation.Resource;
import javax.ejb.Remote;
import javax.ejb.Stateless;
+import javax.jms.Connection;
import javax.jms.ConnectionFactory;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
import org.jboss.messaging.jms.JBossQueue;
-import javax.jms.*;
/**
* A Stateless Bean that will connect to a remote JBM.
@@ -55,22 +57,23 @@
*/
public void sendHello(String message) throws Exception
{
- // Step 4. Define the destination that will receive the message (instead of using JNDI to the remote server)
+ // Step 5. Define the destination that will receive the message (instead of using JNDI to the remote server)
JBossQueue destQueue = new JBossQueue("A");
- // Step 5. Create a connection to a remote server using a connection-factory (look at the deployed file jms-remote-ds.xml)
+ // Step 6. Create a connection to a remote server using a connection-factory (look at the deployed file jms-remote-ds.xml)
Connection conn = connectionFactory.createConnection("guest", "guest");
- // Step 6. Send a message to a remote queue
+ // Step 7. Send a message to a QueueA on the remote server, which will be received by MDBQueueA
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer prod = sess.createProducer(destQueue);
prod.send(sess.createTextMessage(message));
+
+ System.out.println("Step 7 (StatelessSender.java): Sent message \"" + message + "\" to QueueA");
- // Step 7. Close the queue. (Since this is a JCA connection, this will just place the connection back to a connection pool)
- sess.close();
+ // Step 8. Close the connection. (Since this is a JCA connection, this will just place the connection back to a connection pool)
+ conn.close();
+ System.out.println("Step 8 (StatelessSender.java): Closed Connection (sending it back to pool)");
- System.out.println("Sent message \"" + message + "\" on the Stateless");
-
}
// Constants -----------------------------------------------------
More information about the jboss-cvs-commits
mailing list