activemq-artemis/examples/jms/proton-j
Andy Taylor 4b63891aaa ACTIVEMQ6-67 - cleaned up configuration
https://issues.apache.org/jira/browse/ACTIVEMQ6-67

fixed distribution so that file based security works and hot deployers as broken and no longer needed with new bootstrap.

Also combined the jms and core configuration files.
2015-01-15 15:48:22 +00:00
..
src/main ACTIVEMQ6-67 - cleaned up configuration 2015-01-15 15:48:22 +00:00
pom.xml ActiveMQ6-65 JBoss JMS1.1 -> Geronimo 2.0 spec jar 2015-01-07 19:54:42 +00:00
readme.html ACTIVEMQ6-43(reopened) : Replace License Headers on codebase 2015-01-05 13:14:25 -05: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 QPID java 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>Proton qpid java example</h1>

<<p>ActiveMQ is a multi protocol broker. It will inspect the initial handshake of clients to determine what protocol to use.</p>
<p>All you need to do is to connect a client into activemq's configured port and you should be able connect.</p>
<p>To run this example simply run the command <literal>mvn verify</literal>, execute the compile.sh script and start the executable called ./hello</p>

<p>You don't need to do anything special to configure the ActiveMQ server to accept AMQP clients. </p>
<p>Just for the sake of documentation though we are setting the port of ActiveMQ on this example as 5672 which is the port qpid have by default. </p>
<p>This is totally optional and you don't need to follow this convention. You can use any port you chose including ActiveMQ's 5445 default port</p>
     <pre class="prettyprint">
     <code>
         &lt;acceptor name="proton-acceptor"&gt;
         &lt;factory-class&gt;org.apache.activemq.core.remoting.impl.netty.NettyAcceptorFactory&lt;/factory-class&gt;
         &lt;param key="port" value="5672"/&gt;
         &lt;/acceptor&gt;
     </code>
     </pre>
<h2>Example step-by-step</h2>
<ol>
    <li> Create an amqp qpid 1.0 connection.</li>
        <pre class="prettyprint">
           <code>connection= new Connection("localhost", 5672, null, null);</code>
        </pre>

    <li>Create a session</li>
        <pre class="prettyprint">
           <code>Session session = connection.createSession();</code>
        </pre>

    <li>Create a sender</li>
        <pre class="prettyprint">
           <code>Sender sender = session.createSender("testQueue");</code>
        </pre>

    <li>send a simple message</li>
        <pre class="prettyprint">
           <code>sender.send(new Message("I am an amqp message"));</code>
        </pre>

    <li>create a moving receiver, this means the message will be removed from the queue</li>
        <pre class="prettyprint">
           <code>Receiver rec = session.createMovingReceiver("testQueue");</code>
        </pre>

    <li>set some credit so we can receive</li>
        <pre class="prettyprint">
          <code>rec.setCredit(UnsignedInteger.valueOf(1), false);</code>
        </pre>

    <li>receive the simple message</li>
        <pre class="prettyprint">
          <code>Message m = rec.receive(5000);
                System.out.println("message = " + m.getPayload());</code>
        </pre>

    <li>acknowledge the message</li>
        <pre class="prettyprint">
          <code>rec.acknowledge(m);</code>
        </pre>

    <li>close the connection</li>
        <pre class="prettyprint">
          <code>connection.close();</code>
        </pre>
</ol>

</body>
</html>