activemq-artemis/examples/core/vertx-connector
Clebert Suconic 3c44e26854 ACTIVEMQ6-3 renaming directories from activemq6 to activemq
https://issues.apache.org/jira/browse/ACTIVEMQ6-3

We are renaming packages from activemq6 to activemq as that's more generic and version independent
On this first commit I'm just renaming the directories otherwise the history would be lost. The next commit will rename the text on the directories.
If I squash these two commits git will make us delete / add again.
2014-11-17 09:33:36 -05:00
..
src/main ACTIVEMQ6-3 renaming directories from activemq6 to activemq 2014-11-17 09:33:36 -05:00
pom.xml Use new package names in config and classes 2014-11-11 18:28:18 +00:00
readme.html Use new package names in config and classes 2014-11-11 18:28:18 +00:00

readme.html

<html>
  <head>
    <title>HornetQ Vert.x Connector Service 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>Vert.x Connector Service Example</h1>

     <p>This example shows you how to configure HornetQ to use the Vert.x Connector Service.</p>
     
     <p>HornetQ supports 2 types of Vert.x connector, incoming and outgoing.
     Incoming connector consumes from Vert.x event bus and forwards to a configurable address.
     Outgoing connector consumes from a configurable address and forwards to a configurable Vert.x event bus.
     </p>
     
     <p>In this example, an incoming connector and an outgoing connector are configured. A simple java Verticle
     is deployed. The verticle registers a message handler on the outgoing connector's address ("outgoing.vertx.address").
     A String message is sent to Vert.x event bus on the incoming connector's address("incoming.vertx.address"). 
     The message then will be forwarded to a HornetQ queue by the incoming connector. The outgoing connector listens to 
     the HornetQ queue and forwards the message from HornetQ to Vert.x event bus on the outgoing connector's address.
     The verticle finally receives the message from it's event bus.</p>
     
     <p>For more information on Vert.x concept please visit the <a href="http://vertx.io/">Vertx site</a></p>
     
     <h2>Example step-by-step</h2>
     <p><i>To run the server, simply type <code>mvn verify</code>
         from this directory.</p>

     <ol>
        <li>First we need to create a Vert.x PlatformManager</li>
        <pre class="prettyprint">
           <code>platformManager = PlatformLocator.factory.createPlatformManager(PORT, HOST);</code>
        </pre>

        <li>We deploy a Verticle using the platformManager</li>
        <pre class="prettyprint">
           <code>String verticle = "org.apache.activemq6.core.example.ExampleVerticle";
           platformManager.deployVerticle(verticle, null, new URL[0], 1, null, 
                  new Handler<AsyncResult<String>>(){

                     @Override
                     public void handle(AsyncResult<String> result)
                     {
                        if (!result.succeeded())
                        {
                           throw new RuntimeException("failed to deploy verticle", result.cause());
                        }
                        latch0.countDown();
                     }
            
           });</code>
        </pre>

        <li>We register a message handler with the event bus in the Verticle to listen on the outgoing connector's address.</li>
        <pre class="prettyprint">
           <code>EventBus eventBus = vertx.eventBus();
           eventBus.registerHandler(VertxConnectorExample.OUTGOING, 
                      new Handler<Message<?>>() {
                         @Override
                         public void handle(Message<?> startMsg)
                         {
                            Object body = startMsg.body();
                            System.out.println("Verticle receives a message: " + body);
                            VertxConnectorExample.result.set(VertxConnectorExample.MSG.equals(body));
                            latch0.countDown();
                         }
                      });
           </code>
        </pre>

        <li>We send a message to incoming connector's address via event bus</li>
        <pre class="prettyprint">
           <code>
              EventBus bus = platformManager.vertx().eventBus();
              bus.send(INCOMING, MSG);
           </code>
        </pre>

        <li>The message will eventually arrives at the Verticle's message handler.</li>
     </ol>
  </body>
</html>