activemq-artemis/examples/features/standard/bridge
Martyn Taylor c512f12a34 [maven-release-plugin] prepare release 1.1.0 2015-09-11 19:01:19 +01:00
..
src/main Fixing examples on windows 2015-08-30 20:03:32 -04:00
pom.xml [maven-release-plugin] prepare release 1.1.0 2015-09-11 19:01:19 +01:00
readme.html renaming broker-features -> features on examples 2015-08-13 00:11:56 -04:00

readme.html

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF 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.
-->

<html>
  <head>
    <title>ActiveMQ Artemis Core Bridge 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>Core Bridge Example</h1>
     <pre>To run the example, simply type <b>mvn verify</b> from this directory, <br>or <b>mvn -PnoServer verify</b> if you want to start and create the server manually.</pre>

     <p>This example demonstrates a core bridge deployed on one server, which consumes messages from a
     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 ActiveMQ Artemis 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. a WAN.</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 ways, e.g. changing its properties or body</p>
     <p>ActiveMQ Artemis also includes a <b>JMS Bridge</b>. This is similar 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 ActiveMQ Artemis instances, but may provide better performance than the JMS bridge. The JMS bridge is covered in
     a separate example.</p>
     <p>For more information on bridges, please see the ActiveMQ Artemis user manual.</p>

     <p>In this example we will demonstrate a simple sausage factory for aardvarks.</p>
     <p>We have a JMS queue on server 0 named <code>sausage-factory</code>, and we have a
     JMS queue on server 1 named <code>mincing-machine</code></p>
     <p>We want to forward any messages that are sent to the <code>sausage-factory</code> queue on server 0, to the <code>mincing-machine</code>
     on server 1.</p>
     <p>We only want to make aardvark sausages, so we only forward messages where the property "name" is set
     to "aardvark". It is known that other things, such are Sasquatches are also sent to the <code>sausage-factory</code> and we
     want to reject those.</p>
     <p>Moreover it is known that Aardvarks normally wear blue hats, and it's important that we only make sausages using
     Aardvarks with green hats, so on the way we are going transform the property "hat" from "green" to "blue".</p>
     <p>Here's a snippet from <code>broker.xml</code> showing the bridge configuration</p>
     <pre class="prettyprint">
     <code>
     &lt;bridge name="my-bridge"&gt;
          &lt;queue-name&gt;jms.queue.sausage-factory&lt;/queue-name&gt;
          &lt;forwarding-address&gt;jms.queue.mincing-machine&lt;/forwarding-address&gt;
          &lt;filter string="name='aardvark'"/&gt;
          &lt;transformer-class-name&gt;org.apache.activemq.artemis.jms.example.HatColourChangeTransformer&lt;/transformer-class-name&gt;
          &lt;reconnect-attempts&gt;-1&lt;/reconnect-attempts&gt;
          &lt;static-connectors>
             &lt;connector-ref>remote-connector&lt;/connector-ref>
          &lt;/static-connectors>
     &lt;/bridge&gt;
     </code>
     </pre>
  </body>
</html>