[jboss-cvs] JBoss Messaging SVN: r6436 - in trunk: examples/jms and 17 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Apr 15 13:17:23 EDT 2009
Author: timfox
Date: 2009-04-15 13:17:23 -0400 (Wed, 15 Apr 2009)
New Revision: 6436
Added:
trunk/examples/jms/bridge/
trunk/examples/jms/bridge/build.xml
trunk/examples/jms/bridge/readme.html
trunk/examples/jms/bridge/server0/
trunk/examples/jms/bridge/server0/client-jndi.properties
trunk/examples/jms/bridge/server0/jbm-configuration.xml
trunk/examples/jms/bridge/server0/jbm-jms.xml
trunk/examples/jms/bridge/server0/jbm-queues.xml
trunk/examples/jms/bridge/server0/jbm-security.xml
trunk/examples/jms/bridge/server0/jbm-standalone-beans.xml
trunk/examples/jms/bridge/server1/
trunk/examples/jms/bridge/server1/client-jndi.properties
trunk/examples/jms/bridge/server1/jbm-configuration.xml
trunk/examples/jms/bridge/server1/jbm-jms.xml
trunk/examples/jms/bridge/server1/jbm-queues.xml
trunk/examples/jms/bridge/server1/jbm-security.xml
trunk/examples/jms/bridge/server1/jbm-standalone-beans.xml
trunk/examples/jms/bridge/src/
trunk/examples/jms/bridge/src/org/
trunk/examples/jms/bridge/src/org/jboss/
trunk/examples/jms/bridge/src/org/jboss/jms/
trunk/examples/jms/bridge/src/org/jboss/jms/example/
trunk/examples/jms/bridge/src/org/jboss/jms/example/BridgeExample.java
Modified:
trunk/.classpath
trunk/examples/jms/application-layer-failover/
trunk/examples/jms/application-layer-failover/server0/
trunk/examples/jms/application-layer-failover/server1/
trunk/examples/jms/queue-message-redistribution/
trunk/examples/jms/queue-message-redistribution/server0/
trunk/examples/jms/queue-message-redistribution/server1/
trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnection.java
trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
trunk/src/main/org/jboss/messaging/jms/client/JBossConnection.java
Log:
more examples and fixes
Modified: trunk/.classpath
===================================================================
--- trunk/.classpath 2009-04-15 16:03:46 UTC (rev 6435)
+++ trunk/.classpath 2009-04-15 17:17:23 UTC (rev 6436)
@@ -22,6 +22,7 @@
<classpathentry kind="src" path="examples/jms/clustered-durable-subscription/src"/>
<classpathentry kind="src" path="examples/jms/clustered-queue/src"/>
<classpathentry kind="src" path="examples/jms/clustered-topic/src"/>
+ <classpathentry kind="src" path="examples/jms/bridge/src"/>
<classpathentry kind="src" path="examples/jms/common/src"/>
<classpathentry kind="src" path="examples/jms/dead-letter/src"/>
<classpathentry kind="src" path="examples/jms/durable-subscription/src"/>
Property changes on: trunk/examples/jms/application-layer-failover
___________________________________________________________________
Name: svn:ignore
+ build
logs
Property changes on: trunk/examples/jms/application-layer-failover/server0
___________________________________________________________________
Name: svn:ignore
+ data
logs
Property changes on: trunk/examples/jms/application-layer-failover/server1
___________________________________________________________________
Name: svn:ignore
+ data
logs
KILL_ME
Property changes on: trunk/examples/jms/bridge
___________________________________________________________________
Name: svn:ignore
+ build
logs
Added: trunk/examples/jms/bridge/build.xml
===================================================================
--- trunk/examples/jms/bridge/build.xml (rev 0)
+++ trunk/examples/jms/bridge/build.xml 2009-04-15 17:17:23 UTC (rev 6436)
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE project [
+ <!ENTITY libraries SYSTEM "../../../thirdparty/libraries.ent">
+ ]>
+
+<!-- =========================================================================================== -->
+<!-- -->
+<!-- JBoss, Home of Professional Open Source -->
+<!-- Copyright 2005, JBoss Inc., and individual contributors as indicated -->
+<!-- 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. -->
+<!-- -->
+<!-- =========================================================================================== -->
+
+
+<project default="run" name="JBoss Messaging JMS Clustered Queue Example">
+
+ <import file="../common/build.xml"/>
+
+ <target name="run" depends="delete-files">
+ <antcall target="runExample">
+ <param name="example.classname" value="org.jboss.jms.example.BridgeExample"/>
+ <param name="jbm.example.beans.file" value="server0 server1"/>
+ </antcall>
+ </target>
+
+ <target name="runRemote" depends="delete-files">
+ <antcall target="runExample">
+ <param name="example.classname" value="org.jboss.jms.example.BridgeExample"/>
+ <param name="jbm.example.runServer" value="false"/>
+ </antcall>
+ </target>
+
+ <target name="delete-files">
+ <delete dir="./server0/data"/>
+ <delete dir="./server0/logs"/>
+ <delete dir="./server1/data"/>
+ <delete dir="./server1/logs"/>
+ </target>
+
+</project>
Added: trunk/examples/jms/bridge/readme.html
===================================================================
--- trunk/examples/jms/bridge/readme.html (rev 0)
+++ trunk/examples/jms/bridge/readme.html 2009-04-15 17:17:23 UTC (rev 6436)
@@ -0,0 +1,194 @@
+<html>
+ <head>
+ <title>JBoss Messaging Core Bridge Example</title>
+ <link rel="stylesheet" type="text/css" href="../common/common.css">
+ </head>
+ <body>
+ <h1>JBoss Messaging Core Bridge Example</h1>
+ <br>
+
+ <p>This example demonstrates a core bridge deployed on a single server, which consumes messages from a
+ particular local queue and forwards them to an address on a second server.</p>
+
+ <p>Core bridges are used to create message flows between any two JBoss Messaging servers which are remotely separated.
+ Core bridges are resilient and will cope with temporary connection failure allowing them to be an ideal
+ choice for forwarding over unreliable connections, e.g. WANS.</p>
+ <p>They can also be configured with an optional filter expression, and will only forward messages that
+ match that filter.</p>
+ <p>Furthermore they can be configured to use an optional Transformer class. A user defined Transformer class
+ can be specified which is called at forwarding time. This gives the user the opportunity to transform
+ the message in some way, e.g. changing it's properties or body</p>
+ <p>JBoss Messaging also includes a <b>JMS Bridge</b>. This is similar in some ways to a core bridge, but uses the JMS API
+ and can be used to bridge between any two JMS 1.1 compliant messaging systems. The core bridge is limited to bridging
+ between JBoss Messaging instances, but may provide better performance than the JMS bridge.</p>
+ <p>For more information on bridges, please see the JBoss Messaging user manual.</p>
+
+ <h1>TODO not finished</h1>
+
+ <p>This example demonstrates a JMS queue deployed on two different nodes. The two nodes are configured to form a cluster.</p>
+ <p>We then create a consumer on the queue on each node, and we create a producer on only one of the nodes.</p>
+ <p>We then send some messages via the producer, and we verify that <b>both</b> consumers receive the sent messages
+ in a round-robin fashion.</p>
+ <p>In other words, JBoss Messaging <b>load balances</b> the sent messages across all consumers on the cluster</p>
+ <p>This example uses JNDI to lookup the JMS Queue and ConnectionFactory objects. If you prefer not to use
+ JNDI, these could be instantiated directly.</p>
+ <p>Here's the relevant snippet from the server configuration, which tells the server to form a cluster between the two nodes
+ and to load balance the messages between the nodes.</p>
+ <pre>
+ <code>
+ <cluster-connection name="my-cluster">
+ <address>jms</address>
+ <retry-interval>500</retry-interval>
+ <use-duplicate-detection>true</use-duplicate-detection>
+ <forward-when-no-consumers>true</forward-when-no-consumers>
+ <max-hops>1</max-hops>
+ <discovery-group-ref discovery-group-name="my-discovery-group"/>
+ </cluster-connection>
+ </code>
+ </pre>
+ <p>For more information on JBoss Messaging load balancing, and clustering in general, please see the clustering
+ section of the user manual.</p>
+ <h2>Example step-by-step</h2>
+ <p><i>To run the example, simply type <code>ant</code> from this directory</i></p>
+ <br>
+ <ol>
+ <li> Get an initial context for looking up JNDI from server 0.</li>
+ <pre>
+ <code>
+ ic0 = getContext(0);
+ </code>
+ </pre>
+
+ <li>Look-up the JMS Queue object from JNDI</li>
+ <pre>
+ <code>Queue queue = (Queue)ic0.lookup("/queue/exampleQueue");</code>
+ </pre>
+
+ <li>Look-up a JMS Connection Factory object from JNDI on server 0</li>
+ <pre>
+ <code>ConnectionFactory cf0 = (ConnectionFactory)ic0.lookup("/ConnectionFactory");</code>
+ </pre>
+
+ <li>Get an initial context for looking up JNDI from server 1.</li>
+ <pre>
+ <code>ic1 = getContext(1);</code>
+ </pre>
+
+ <li>Look-up a JMS Connection Factory object from JNDI on server 1</li>
+ <pre>
+ <code>ConnectionFactory cf1 = (ConnectionFactory)ic1.lookup("/ConnectionFactory");
+ </code>
+ </pre>
+
+ <li>We create a JMS Connection connection0 which is a connection to server 0</li>
+ <pre>
+ <code>
+ connection0 = cf0.createConnection();
+ </code>
+ </pre>
+
+ <li>We create a JMS Connection connection1 which is a connection to server 1</li>
+ <pre>
+ <code>
+ connection1 = cf1.createConnection();
+ </code>
+ </pre>
+
+ <li>We create a JMS Session on server 0</li>
+ <pre>
+ <code>
+ Session session0 = connection0.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ </code>
+ </pre>
+
+ <li>We create a JMS Session on server 1</li>
+ <pre>
+ <code>
+ Session session1 = connection1.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ </code>
+ </pre>
+
+ <li>We start the connections to ensure delivery occurs on them</li>
+ <pre>
+ <code>
+ connection0.start();
+
+ connection1.start();
+ </code>
+ </pre>
+
+ <li>We create JMS MessageConsumer objects on server 0 and server 1</li>
+ <pre>
+ <code>
+ MessageConsumer consumer0 = session0.createConsumer(queue);
+
+ MessageConsumer consumer1 = session1.createConsumer(queue);
+ </code>
+ </pre>
+
+ <li>We create a JMS MessageProducer object on server 0.</li>
+ <pre>
+ <code>
+ MessageProducer producer = session0.createProducer(queue);</code>
+ </pre>
+
+ <li>We send some messages to server 0.</li>
+ <pre>
+ <code>
+ final int numMessages = 10;
+
+ for (int i = 0; i < numMessages; i++)
+ {
+ TextMessage message = session0.createTextMessage("This is text message " + i);
+
+ producer.send(message);
+
+ System.out.println("Sent message: " + message.getText());
+ }
+ </code>
+ </pre>
+
+ <li>We now consume those messages on *both* server 0 and server 1.
+ We note the messages have been distributed between servers in a round robin fashion.
+ JBoss Messaging has <b>load balanced</b> the messages between the available consumers on the different nodes.
+ JBoss Messaging can be configured to always load balance messages to all nodes, or to only balance messages
+ to nodes which have consumers with no or matching selectors. See the user manual for more details.</li>
+ JMS Queues implement point-to-point message where each message is only ever consumed by a
+ maximum of one consumer.
+ <pre>
+ <code>
+ for (int i = 0; i < numMessages; i += 2)
+ {
+ TextMessage message0 = (TextMessage)consumer0.receive(5000);
+
+ System.out.println("Got message: " + message0.getText() + " from node 0");
+
+ TextMessage message1 = (TextMessage)consumer1.receive(5000);
+
+ System.out.println("Got message: " + message1.getText() + " from node 1");
+ }
+ </code>
+ </pre>
+
+ <li>And finally (no pun intended), <b>always</b> remember to close your JMS resources after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
+
+ <pre>
+ <code>
+ finally
+ {
+ if (connection0 != null)
+ {
+ connection0.close();
+ }
+
+ if (connection1 != null)
+ {
+ connection1.close();
+ }
+ }
+ </code>
+ </pre>
+
+ </ol>
+ </body>
+</html>
\ No newline at end of file
Property changes on: trunk/examples/jms/bridge/server0
___________________________________________________________________
Name: svn:ignore
+ data
logs
Added: trunk/examples/jms/bridge/server0/client-jndi.properties
===================================================================
--- trunk/examples/jms/bridge/server0/client-jndi.properties (rev 0)
+++ trunk/examples/jms/bridge/server0/client-jndi.properties 2009-04-15 17:17:23 UTC (rev 6436)
@@ -0,0 +1,3 @@
+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
Added: trunk/examples/jms/bridge/server0/jbm-configuration.xml
===================================================================
--- trunk/examples/jms/bridge/server0/jbm-configuration.xml (rev 0)
+++ trunk/examples/jms/bridge/server0/jbm-configuration.xml 2009-04-15 17:17:23 UTC (rev 6436)
@@ -0,0 +1,48 @@
+<deployment xmlns="urn:jboss:messaging"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:messaging ../schemas/jbm-configuration.xsd">
+ <configuration>
+
+ <clustered>true</clustered>
+
+ <!-- Connectors -->
+
+ <connector name="netty-connector">
+ <factory-class>org.jboss.messaging.integration.transports.netty.NettyConnectorFactory</factory-class>
+ <param key="jbm.remoting.netty.port" value="5445" type="Integer"/>
+ </connector>
+
+ <!-- Connector to the other node -->
+ <connector name="remote-connector">
+ <factory-class>org.jboss.messaging.integration.transports.netty.NettyConnectorFactory</factory-class>
+ <param key="jbm.remoting.netty.port" value="5446" type="Integer"/>
+ </connector>
+
+ <!-- Acceptors -->
+
+ <acceptor name="netty-acceptor">
+ <factory-class>org.jboss.messaging.integration.transports.netty.NettyAcceptorFactory</factory-class>
+ <param key="jbm.remoting.netty.port" value="5445" type="Integer"/>
+ </acceptor>
+
+ <queue name="jms.queue.sausage-factory" address="jms.queue.sausage-factory"/>
+
+ <!-- We set-up a bridge that forwards from a queue on this node to an address on another node.
+ We specify a filter with the bridge, and a transformer too. The filter and transformer are optional -->
+
+ <bridge name="my-bridge">
+ <queue-name>jms.queue.sausage-factory</queue-name>
+ <forwarding-address>jms.queue.mincing-machine</forwarding-address>
+ <filter string="president='bush'"/>
+ <transformer-class-name>org.jboss.jms.example.PokeEyeTransformer</transformer-class-name>
+ <reconnect-attempts>-1</reconnect-attempts>
+ <connector-ref connector-name="remote-connector"/>
+ </bridge>
+
+ <!-- Other config -->
+
+ <journal-min-files>2</journal-min-files>
+
+ </configuration>
+
+</deployment>
Added: trunk/examples/jms/bridge/server0/jbm-jms.xml
===================================================================
--- trunk/examples/jms/bridge/server0/jbm-jms.xml (rev 0)
+++ trunk/examples/jms/bridge/server0/jbm-jms.xml 2009-04-15 17:17:23 UTC (rev 6436)
@@ -0,0 +1,18 @@
+<deployment xmlns="urn:jboss:messaging"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:messaging ../schemas/jbm-jms.xsd ">
+ <!--the connection factory used by the example-->
+ <connection-factory name="ConnectionFactory">
+ <connector-ref connector-name="netty-connector"/>
+ <entry name="ConnectionFactory"/>
+ <entry name="XAConnectionFactory"/>
+ <entry name="java:/ConnectionFactory"/>
+ <entry name="java:/XAConnectionFactory"/>
+ </connection-factory>
+
+ <!--the queue used by the example-->
+ <queue name="sausage-factory">
+ <entry name="/queue/sausage-factory"/>
+ </queue>
+
+</deployment>
\ No newline at end of file
Added: trunk/examples/jms/bridge/server0/jbm-queues.xml
===================================================================
--- trunk/examples/jms/bridge/server0/jbm-queues.xml (rev 0)
+++ trunk/examples/jms/bridge/server0/jbm-queues.xml 2009-04-15 17:17:23 UTC (rev 6436)
@@ -0,0 +1,15 @@
+<settings xmlns="urn:jboss:messaging"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:messaging ../schemas/jbm-queues.xsd ">
+
+ <!--security for example queue-->
+ <security match="jms.queue.#">
+ <permission type="createDurableQueue" roles="guest"/>
+ <permission type="deleteDurableQueue" roles="guest"/>
+ <permission type="createTempQueue" roles="guest"/>
+ <permission type="deleteTempQueue" roles="guest"/>
+ <permission type="consume" roles="guest"/>
+ <permission type="send" roles="guest"/>
+ </security>
+
+</settings>
Added: trunk/examples/jms/bridge/server0/jbm-security.xml
===================================================================
--- trunk/examples/jms/bridge/server0/jbm-security.xml (rev 0)
+++ trunk/examples/jms/bridge/server0/jbm-security.xml 2009-04-15 17:17:23 UTC (rev 6436)
@@ -0,0 +1,7 @@
+<deployment xmlns="urn:jboss:messaging" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:messaging ../schemas/jbm-security.xsd ">
+ <!-- the default user. this is used where username is null-->
+ <defaultuser name="guest" password="guest">
+ <role name="guest"/>
+ </defaultuser>
+</deployment>
\ No newline at end of file
Added: trunk/examples/jms/bridge/server0/jbm-standalone-beans.xml
===================================================================
--- trunk/examples/jms/bridge/server0/jbm-standalone-beans.xml (rev 0)
+++ trunk/examples/jms/bridge/server0/jbm-standalone-beans.xml 2009-04-15 17:17:23 UTC (rev 6436)
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<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">1099</property>
+ <property name="bindAddress">localhost</property>
+ <property name="rmiPort">1098</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.jboss.messaging.core.config.impl.FileConfiguration"/>
+
+ <!-- The security manager -->
+ <bean name="JBMSecurityManager" class="org.jboss.messaging.core.security.impl.JBMSecurityManagerImpl">
+ <start ignored="true"/>
+ <stop ignored="true"/>
+ </bean>
+
+ <!-- The core server -->
+ <bean name="MessagingServer" class="org.jboss.messaging.core.server.impl.MessagingServerImpl">
+ <constructor>
+ <parameter>
+ <inject bean="Configuration"/>
+ </parameter>
+ <parameter>
+ <inject bean="MBeanServer"/>
+ </parameter>
+ <parameter>
+ <inject bean="JBMSecurityManager"/>
+ </parameter>
+ </constructor>
+ </bean>
+
+ <!-- The JMS server -->
+ <bean name="JMSServerManager" class="org.jboss.messaging.jms.server.impl.JMSServerManagerImpl">
+ <constructor>
+ <parameter>
+ <inject bean="MessagingServer"/>
+ </parameter>
+ </constructor>
+ </bean>
+
+
+</deployment>
\ No newline at end of file
Property changes on: trunk/examples/jms/bridge/server1
___________________________________________________________________
Name: svn:ignore
+ data
logs
Added: trunk/examples/jms/bridge/server1/client-jndi.properties
===================================================================
--- trunk/examples/jms/bridge/server1/client-jndi.properties (rev 0)
+++ trunk/examples/jms/bridge/server1/client-jndi.properties 2009-04-15 17:17:23 UTC (rev 6436)
@@ -0,0 +1,3 @@
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.provider.url=jnp://localhost:2099
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
Added: trunk/examples/jms/bridge/server1/jbm-configuration.xml
===================================================================
--- trunk/examples/jms/bridge/server1/jbm-configuration.xml (rev 0)
+++ trunk/examples/jms/bridge/server1/jbm-configuration.xml 2009-04-15 17:17:23 UTC (rev 6436)
@@ -0,0 +1,28 @@
+<deployment xmlns="urn:jboss:messaging"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:messaging ../schemas/jbm-configuration.xsd">
+ <configuration>
+
+ <clustered>true</clustered>
+
+ <!-- Connectors -->
+
+ <connector name="netty-connector">
+ <factory-class>org.jboss.messaging.integration.transports.netty.NettyConnectorFactory</factory-class>
+ <param key="jbm.remoting.netty.port" value="5446" type="Integer"/>
+ </connector>
+
+ <!-- Acceptors -->
+
+ <acceptor name="netty-acceptor">
+ <factory-class>org.jboss.messaging.integration.transports.netty.NettyAcceptorFactory</factory-class>
+ <param key="jbm.remoting.netty.port" value="5446" type="Integer"/>
+ </acceptor>
+
+ <!-- Other config -->
+
+ <journal-min-files>2</journal-min-files>
+
+ </configuration>
+
+</deployment>
Added: trunk/examples/jms/bridge/server1/jbm-jms.xml
===================================================================
--- trunk/examples/jms/bridge/server1/jbm-jms.xml (rev 0)
+++ trunk/examples/jms/bridge/server1/jbm-jms.xml 2009-04-15 17:17:23 UTC (rev 6436)
@@ -0,0 +1,18 @@
+<deployment xmlns="urn:jboss:messaging"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:messaging ../schemas/jbm-jms.xsd ">
+ <!--the connection factory used by the example-->
+ <connection-factory name="ConnectionFactory">
+ <connector-ref connector-name="netty-connector"/>
+ <entry name="ConnectionFactory"/>
+ <entry name="XAConnectionFactory"/>
+ <entry name="java:/ConnectionFactory"/>
+ <entry name="java:/XAConnectionFactory"/>
+ </connection-factory>
+
+ <!--the queue used by the example-->
+ <queue name="mincing-machine">
+ <entry name="/queue/mincing-machine"/>
+ </queue>
+
+</deployment>
\ No newline at end of file
Added: trunk/examples/jms/bridge/server1/jbm-queues.xml
===================================================================
--- trunk/examples/jms/bridge/server1/jbm-queues.xml (rev 0)
+++ trunk/examples/jms/bridge/server1/jbm-queues.xml 2009-04-15 17:17:23 UTC (rev 6436)
@@ -0,0 +1,15 @@
+<settings xmlns="urn:jboss:messaging"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:messaging ../schemas/jbm-queues.xsd ">
+
+ <!--security for example queue-->
+ <security match="jms.queue.#">
+ <permission type="createDurableQueue" roles="guest"/>
+ <permission type="deleteDurableQueue" roles="guest"/>
+ <permission type="createTempQueue" roles="guest"/>
+ <permission type="deleteTempQueue" roles="guest"/>
+ <permission type="consume" roles="guest"/>
+ <permission type="send" roles="guest"/>
+ </security>
+
+</settings>
Added: trunk/examples/jms/bridge/server1/jbm-security.xml
===================================================================
--- trunk/examples/jms/bridge/server1/jbm-security.xml (rev 0)
+++ trunk/examples/jms/bridge/server1/jbm-security.xml 2009-04-15 17:17:23 UTC (rev 6436)
@@ -0,0 +1,7 @@
+<deployment xmlns="urn:jboss:messaging" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:messaging ../schemas/jbm-security.xsd ">
+ <!-- the default user. this is used where username is null-->
+ <defaultuser name="guest" password="guest">
+ <role name="guest"/>
+ </defaultuser>
+</deployment>
\ No newline at end of file
Added: trunk/examples/jms/bridge/server1/jbm-standalone-beans.xml
===================================================================
--- trunk/examples/jms/bridge/server1/jbm-standalone-beans.xml (rev 0)
+++ trunk/examples/jms/bridge/server1/jbm-standalone-beans.xml 2009-04-15 17:17:23 UTC (rev 6436)
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<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">2099</property>
+ <property name="bindAddress">localhost</property>
+ <property name="rmiPort">2098</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.jboss.messaging.core.config.impl.FileConfiguration"/>
+
+ <!-- The security manager -->
+ <bean name="JBMSecurityManager" class="org.jboss.messaging.core.security.impl.JBMSecurityManagerImpl">
+ <start ignored="true"/>
+ <stop ignored="true"/>
+ </bean>
+
+ <!-- The core server -->
+ <bean name="MessagingServer" class="org.jboss.messaging.core.server.impl.MessagingServerImpl">
+ <constructor>
+ <parameter>
+ <inject bean="Configuration"/>
+ </parameter>
+ <parameter>
+ <inject bean="MBeanServer"/>
+ </parameter>
+ <parameter>
+ <inject bean="JBMSecurityManager"/>
+ </parameter>
+ </constructor>
+ </bean>
+
+ <!-- The JMS server -->
+ <bean name="JMSServerManager" class="org.jboss.messaging.jms.server.impl.JMSServerManagerImpl">
+ <constructor>
+ <parameter>
+ <inject bean="MessagingServer"/>
+ </parameter>
+ </constructor>
+ </bean>
+
+</deployment>
\ No newline at end of file
Added: trunk/examples/jms/bridge/src/org/jboss/jms/example/BridgeExample.java
===================================================================
--- trunk/examples/jms/bridge/src/org/jboss/jms/example/BridgeExample.java (rev 0)
+++ trunk/examples/jms/bridge/src/org/jboss/jms/example/BridgeExample.java 2009-04-15 17:17:23 UTC (rev 6436)
@@ -0,0 +1,147 @@
+/*
+ * 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.jms.example;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+
+/**
+ * This example demonstrates a core bridge set-up between two nodes, consuming messages from a queue
+ * on one node and forwarding them to an address on the second node.
+ *
+ * @author <a href="tim.fox at jboss.com>Tim Fox</a>
+ */
+public class BridgeExample extends JMSExample
+{
+ public static void main(String[] args)
+ {
+ new BridgeExample().run(args);
+ }
+
+ public boolean runExample() throws Exception
+ {
+ Connection connection0 = null;
+
+ Connection connection1 = null;
+
+ InitialContext ic0 = null;
+
+ InitialContext ic1 = null;
+
+ try
+ {
+ ic0 = getContext(0);
+
+ Queue sausageFactory = (Queue)ic0.lookup("/queue/sausage-factory");
+
+ ConnectionFactory cf0 = (ConnectionFactory)ic0.lookup("/ConnectionFactory");
+
+
+ ic1 = getContext(1);
+
+ Queue mincingMachine = (Queue)ic1.lookup("/queue/mincing-machine");
+
+ ConnectionFactory cf1 = (ConnectionFactory)ic1.lookup("/ConnectionFactory");
+
+
+ // Step 6. We create a JMS Connection connection0 which is a connection to server 0
+ connection0 = cf0.createConnection();
+
+ // Step 7. We create a JMS Connection connection1 which is a connection to server 1
+ connection1 = cf1.createConnection();
+
+ // Step 8. We create a JMS Session on server 0
+ Session session0 = connection0.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ // Step 9. We create a JMS Session on server 1
+ Session session1 = connection1.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ // Step 10. We start the connection to ensure delivery occurs on them
+
+ connection1.start();
+
+ // Step 11. We create JMS MessageConsumer objects
+ MessageConsumer consumer = session1.createConsumer(mincingMachine);
+
+ // Step 12. We create a JMS MessageProducer object on server 0
+ MessageProducer producer = session0.createProducer(sausageFactory);
+
+ Message message = session0.createMessage();
+
+ message.setStringProperty("president", "bush");
+
+ message.setStringProperty("eye", "not poked yet");
+
+ producer.send(message);
+
+ Message receivedMessage = consumer.receive(5000);
+
+ System.out.println("Received message " + receivedMessage.getStringProperty("eye"));
+
+ message = session0.createMessage();
+
+ message.setStringProperty("president", "obama");
+
+ message.setStringProperty("eye", "not poked yet");
+
+ producer.send(message);
+
+ receivedMessage = (TextMessage)consumer.receive(1000);
+
+ System.out.println("Received message " + receivedMessage);
+
+ return true;
+ }
+ finally
+ {
+ // Step 15. Be sure to close our resources!
+
+ if (connection0 != null)
+ {
+ connection0.close();
+ }
+
+ if (connection1 != null)
+ {
+ connection1.close();
+ }
+
+ if (ic0 != null)
+ {
+ ic0.close();
+ }
+
+ if (ic1 != null)
+ {
+ ic1.close();
+ }
+ }
+ }
+
+}
Property changes on: trunk/examples/jms/queue-message-redistribution
___________________________________________________________________
Name: svn:ignore
+ build
logs
Property changes on: trunk/examples/jms/queue-message-redistribution/server0
___________________________________________________________________
Name: svn:ignore
+ data
logs
Property changes on: trunk/examples/jms/queue-message-redistribution/server1
___________________________________________________________________
Name: svn:ignore
+ data
logs
Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnection.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnection.java 2009-04-15 16:03:46 UTC (rev 6435)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnection.java 2009-04-15 17:17:23 UTC (rev 6436)
@@ -32,7 +32,6 @@
import org.jboss.messaging.core.remoting.spi.ConnectionLifeCycleListener;
import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
import org.jboss.messaging.utils.ExecutorFactory;
-import org.jboss.messaging.utils.Future;
import org.jboss.messaging.utils.JBMThreadFactory;
import org.jboss.messaging.utils.OrderedExecutorFactory;
import org.jboss.messaging.utils.UUIDGenerator;
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java 2009-04-15 16:03:46 UTC (rev 6435)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java 2009-04-15 17:17:23 UTC (rev 6436)
@@ -388,9 +388,6 @@
resourceManager.start();
- // Deploy any pre-defined queues
- deployQueues();
-
// Deply any pre-defined diverts
deployDiverts();
@@ -446,8 +443,6 @@
uuid,
replicatingChannel,
configuration.isBackup());
-
- clusterManager.start();
}
// We need to startDepage when we restart the server to eventually resume destinations that were in depage mode
@@ -485,6 +480,14 @@
// Once we ready we can start the remoting service so we can start accepting connections
remotingService.start();
}
+
+ // Deploy any pre-defined queues
+ deployQueues();
+
+ if (clusterManager != null)
+ {
+ clusterManager.start();
+ }
started = true;
}
Modified: trunk/src/main/org/jboss/messaging/jms/client/JBossConnection.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/client/JBossConnection.java 2009-04-15 16:03:46 UTC (rev 6435)
+++ trunk/src/main/org/jboss/messaging/jms/client/JBossConnection.java 2009-04-15 17:17:23 UTC (rev 6436)
@@ -413,6 +413,11 @@
{
sessions.remove(session);
}
+
+ public ClientSession getInitialSession()
+ {
+ return initialSession;
+ }
// Package protected ----------------------------------------------------------------------------
@@ -501,7 +506,9 @@
{
try
{
- initialSession = sessionFactory.createSession(username, password, false, false, false, false, 0);
+ initialSession = sessionFactory.createSession(username, password, false, false, false, false, 0);
+
+ initialSession.addFailureListener(listener);
}
catch (MessagingException me)
{
@@ -513,8 +520,16 @@
private class JMSFailureListener implements FailureListener
{
- public boolean connectionFailed(final MessagingException me)
+ //Make sure it's only called once
+ private boolean failed;
+
+ public synchronized boolean connectionFailed(final MessagingException me)
{
+ if (failed)
+ {
+ return true;
+ }
+
if (me == null)
{
return true;
@@ -528,6 +543,8 @@
exceptionListener.onException(je);
}
+
+ failed = true;
return true;
}
More information about the jboss-cvs-commits
mailing list