-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAppendixA-ActiveMQ.html
80 lines (59 loc) · 5.03 KB
/
AppendixA-ActiveMQ.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<section data-type="appendix" id="appendix_activemq" xmlns="http://www.w3.org/1999/xhtml">
<h1>Apache ActiveMQ</h1>
<p class="lead">In this appendix, we describe how to install and configure <a href="http://activemq.apache.org">Apache ActiveMQ</a> to support STOMP and <a contenteditable="false" data-primary="Apache ActiveMQ" data-see="ActiveMQ" data-type="indexterm"> </a>MQTT protocols.<a contenteditable="false" data-primary="ActiveMQ" data-type="indexterm" id="ActiveMQ"> </a></p>
<p>The Apache ActiveMQ is a popular and powerful open source messaging server. It is fast, and supports many cross-language clients and protocols. In this book, we will connect to it from the Objective-C and JavaScript languages using two messaging protocols: STOMP and MQTT.</p>
<section data-type="sect1" id="_download_and_installation">
<h1>Download and Installation</h1>
<p>Apache ActiveMQ latest release at the time of writing this book is 5.9.0. It can be downloaded from its <a href="http://bit.ly/activemq-590">download page</a> and the <a href="http://bit.ly/start-activemq">getting started page</a> contains all the information to install it.<a contenteditable="false" data-primary="ActiveMQ" data-secondary="downloading and installing" data-type="indexterm"> </a></p>
<p>For our setup, ActiveMQ will be installed in the directory <em>~/mobilewebmsg/mybroker</em>.</p>
<p>After you have downloaded the archive for ActiveMQ, it can be installed and started by running the commands:</p>
<pre data-code-language="sh" data-type="programlisting">
$ tar zxvf apache-activemq-5.9.0-bin.tar.gz
$ cd apache-activemq-5.9.0
$ mkdir ~/mobilewebmsg/
$ ./bin/activemq create ~/mobilewebmsg/mybroker
...
$ cd ~/mobilewebmsg/mybroker
$ ./bin/mybroker start
...
$ tail data/activemq.log
...
2014-06-11 15:17:17,113 | INFO | Apache ActiveMQ 5.9.0 (mybroker, ID:jeff.local-50723-1402492636703-0:1) started |
org.apache.activemq.broker.BrokerService | main
...</pre>
<p>To stop the broker, run the following command:</p>
<pre data-code-language="sh" data-type="programlisting">
$ ./bin/mybroker stop
...
Stopping broker: mybroker
.... FINISHED</pre>
</section>
<section data-type="sect1" id="app_activemq_admin_console">
<h1>Administration Web Console</h1>
<p>When the broker is started, it can be administered and managed using its web console running at <em>http://localhost:8161/hawtio></em>. Out of the box, you can log into the admin console using the <strong><code>admin</code></strong> / <strong><code>admin</code></strong> credentials.<a contenteditable="false" data-primary="ActiveMQ" data-secondary="administration web console" data-type="indexterm"> </a></p>
<p>After you are logged in, you can check the <code>mybroker</code> resource in the ActiveMQ tree, as illustrated in <a data-type="xref" href="img_app_activemq_1">img_app_activemq_1</a>.</p>
<figure id="img_app_activemq_1"><img alt="The mybroker resource in ActiveMQ Web console" src="images/mawm_aa01.png" />
<figcaption>The mybroker resource in the ActiveMQ web console</figcaption>
</figure>
<p>One interesting attribute is <code>transportConnectors</code>. If you click on the attribute value, a pop-up screen opens and display all the protocols supported by ActiveMQ out of the box (<a data-type="xref" href="img_app_activemq_2">img_app_activemq_2</a>).<a contenteditable="false" data-primary="transport connectors (ActiveMQ)" data-type="indexterm"> </a></p>
<figure id="img_app_activemq_2"><img alt="ActiveMQ Default Transport Connectors" src="images/mawm_aa02.png" />
<figcaption>ActiveMQ default transport connectors</figcaption>
</figure>
<p>For this book, the important ones are:</p>
<ul>
<li>
<p>Stomp (<code>stomp://jeff.local:61613</code>)</p>
</li>
<li>
<p>Mqtt (<code>mqtt://jeff.local:1883</code>)</p>
</li>
<li>
<p>Ws (<code>ws://jeff.local:61614</code>)</p>
</li>
</ul>
<p>They mean that to connect to ActiveMQ using the STOMP protocol<a contenteditable="false" data-primary="STOMP" data-secondary="connecting to ActiveMQ with" data-type="indexterm"> </a> we must connect to the <code>jeff.local</code> host (this is the name of my machine on my local network; your ActiveMQ installation will have another value) on the port <code>61613</code>.</p>
<p>Likewise, to connect to ActiveMQ using the MQTT protocol, we must again use the <code>jeff.local</code> host, but on the port <code>1883</code> this time.<a contenteditable="false" data-primary="MQTT" data-secondary="connecting to ActiveMQ with" data-type="indexterm"> </a></p>
<p>Finally, there is also the Web Socket connector that must be used to connect from a web browser, <em>regardless</em> of the messaging protocol that we use.<a contenteditable="false" data-primary="Web Sockets" data-secondary="ActiveMQ transport connector" data-type="indexterm"> </a> A web application would have to connect to the <code>61614</code> port regardless of whether the application is using STOMP or MQTT.<br />
<a contenteditable="false" data-primary="message acknowledgement in STOMP" data-startref="ActiveMQ" data-type="indexterm"> </a></p>
</section>
</section>