This document summarizes a presentation given by Rob Davies at the CamelOne 2013 conference in Boston, MA on June 10-11, 2013. The presentation introduced Apache ActiveMQ, an open-source message broker, and discussed its features including messaging protocols, management tools, high availability, and integration with Apache Camel. It also covered challenges of deploying and maintaining large ActiveMQ clusters and how Red Hat Fuse Fabric can help address these challenges.
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Â
Connecting Applications Everywhere with ActiveMQ
1. CamelOne 2013
June 10-11 2013
Boston, MA
1
Connecting Applications
Everywhere with
ActiveMQ
Rob Davies
Technical Director, Fuse Engineering,
Red Hat Inc.
2. CamelOne 2013
CamelOne
2
Rob Davies
Technical Director, Red Hat -
h"p://www.redhat.com
â ⯠Previously CTO of FuseSource - #1 OS
vendor for integration and messaging
â ⯠Software projects:
â ⯠Apache ActiveMQ,
â ⯠Apache Camel
â ⯠Apache ServiceMix
â ⯠On
 Expert
 Group
 for
 JSR
 343:
 JMS
 2.0
Â
â ⯠Co-Ââauthor
 of
 AcCveMQ
 in
 AcCon:
Â
3. CamelOne 2013
CamelOne
Why use Message-
Oriented Middleware?
ď§âŻ Robustness
 to
 change
Â
ď§âŻ Time
 Independence
Â
ď§âŻ LocaCon
 Independence
Â
ď§âŻ Hide
 Latency
Â
ď§âŻ Scalability
Â
ď§âŻ Event
 driven
Â
ď§âŻ Simplicity
Â
ď§âŻ ConďŹgurable
 Quality
 of
 Service
Â
ď§âŻ PlaRorm
 and
 Language
 IntegraCon
Â
ď§âŻ Fault
 tolerant
Â
Â
4. CamelOne 2013
CamelOne
4
What is Apache ActiveMQ ?
â âŻTop Level Apache Software Foundation Project
â âŻWildly popular, high performance, reliable message
broker
â âŻConnects to nearly everything
â âŻNative Java, C/C++, .Net,
â âŻAMQP 1.0, MQTT 3.1, STOMP (1.0-1.2) and
OpenWire
â âŻSTOMP enables Ruby, JS, Perl, Python, PHP,
ActionScript âŚ
â âŻEmbedded and standalone deployment options
6. CamelOne 2013
CamelOne
Message Channels and
Routing
â˘âŻ Message Channels
â˘âŻ Named communication between interested parties
â˘âŻ JMS calls them âDestinationsâ
â˘âŻ Can âtune-inâ to multiple channels using wildcards
â˘âŻ Can ďŹne-tune message consumption with selectors
â˘âŻ Can route a message based on content
13. CamelOne 2013
CamelOne
Message Groups
Like Parallel Exclusive Consumers
â âŻGuaranteed ordering of related messages across a
Queue
â âŻBut â load balancing of messages across multiple
consumers
â âŻAll messages with the same JMSXGroupID go to
the same consumer
â âŻHow you group messages is down to the applicationâs
producer
â âŻTo explicitly close a group, set the JMSXGroupSeq
to -1
13
14. CamelOne 2013
CamelOne
14
Message Groups code:
Message message = session.createTextMessage("<foo>hi from Devoxx</foo>");
message.setStringProperty("JMSXGroupID", âRHT_NYSE");
producer.send(message);
Message message = session.createTextMessage(foobye from Devoxx/foo);
message.setStringProperty(JMSXGroupID, âRHT_NYSE);
message.setStringProperty(JMSXGroupSeq, -1);
producer.send(message);
//Starting a Group âŚ
//Close a Group âŚ
15. CamelOne 2013
CamelOne
Deploying ActiveMQ
ActiveMQ Can run standalone or embedded
â âŻAs a standalone, or part of a highly available message
broker cluster
â âŻEmbedded â easy to use an entire broker in JUnit tests
(no need to Mock)
â âŻIn Tomcat, deployed as a war
â âŻIn JEE Server â either co-locate â or use client with JCA
â âŻActiveMQ distributions contain a rar for this purpose
15
17. CamelOne 2013
CamelOne
Message Delivery Mode
â˘âŻ Messages can be persisted â allowing for
decoupled applications
â˘âŻ For Queues, any message delivered as
PERSISTENT must be stored on long term storage
before being delivered to a consumer
â˘âŻ For Topics, a message delivered as PERSISTENT
will only be stored if there exists a durable subscriber
â˘âŻ NON-PERSISTENT messages may also be stored
on disk if the memory limits of the broker have been
reached
17
18. CamelOne 2013
CamelOne
Message stores supported by
ActiveMQ
â âŻSQL (JDBC)
â âŻSQL (JDBC) with journal
â âŻAMQ Message Store
â âŻKaha
â âŻKahaDB
â âŻLevelDB
18
Slow but
popular
Donât use
(deprecated)
The âcurrentâ
default
The âbest yetâ
19. CamelOne 2013
CamelOne
LevelDB Store vs KahaDB
â˘âŻ Fewer index entries per message than KahaDB
â˘âŻ Faster recovery when a broker restarts
â˘âŻ LevelDB index out-perform Btree index at sequential access .
â˘âŻ LevelDB indexes support concurrent read access.
â˘âŻ Pauseless data log ďŹle garbage collection cycles.
â˘âŻ Fewer IOPS to load stored messages.
â˘âŻ It exposes it's status via JMX for monitoring
22. CamelOne 2013
CamelOne
OpenWire
Advantages:
â˘âŻ Fast â optimized for
ActiveMQ
â˘âŻ client failover
â˘âŻ automatic reconnect
â˘âŻ Client load balancing
â˘âŻ Flow control
â˘âŻ Many advanced features
22
Disadvantages:
â˘âŻ Not a recognized
standard
â˘âŻ Only Java, C/C++/.Net
http://activemq.apache.org/openwire.html
23. CamelOne 2013
CamelOne
MQTT http://mqtt.org
Advantages:
â˘âŻ M2M/âInternet of Thingsâ transport
â˘âŻ Proposed as an OASIS standard
â˘âŻ Extremely light weight
â˘âŻ Growing support from vendors and OS
products
â˘âŻ WebSphereMQ
â˘âŻ ActiveMQ + Apollo
â˘âŻ Mosquitto
â˘âŻ RabbitMQ
23
Disadvantages:
â˘âŻ 3.1 does not support
Queues
â˘âŻ Advanced features not
standard
â˘âŻ Flow control
â˘âŻ Failover etc.
24. CamelOne 2013
CamelOne
AMQP â see www.amqp.org
Advantages:
â˘âŻ AMQP 1.0 OASIS
standard
â˘âŻ Proposed as an OASIS
standard
â˘âŻ Commoditizes the
Broker
24
Disadvantages:
â˘âŻ One size doesnât really ďŹt
all
â˘âŻ Currently no plans for IBM
or Tibco to adopt it
25. CamelOne 2013
CamelOne
STOMP â http://stomp.github.com
Advantages:
â˘âŻ Easy to use text based
protocol
â˘âŻ Can use telnet as a client
â˘âŻ Defacto standard:
â˘âŻ ActiveMQ + Apollo
â˘âŻ HornetQ
â˘âŻ RabbitMQ
â˘âŻ PocoMQ
â˘âŻ StompServer
â˘âŻ OpenMQ
â˘âŻ Many more âŚ
25
Disadvantages:
â˘âŻ Not as fast as binary
formats
26. CamelOne 2013
CamelOne
But thereâs more: WebSockets
STOMP is a natural wire protocol for WebSockets
26
ActiveMQ
Client
(Browser)
WebSocket
Connector
Stomp
Converter
ActiveMQ
(Backend)
TCP
(WebSocket)
HTTP(S)
Request/Response
1. HTTP Request (Upgrade)
2. HTTP Response
4. Message received
from Topic
5. Send WebSocket
Data
3. Stomp Subscribe
36. CamelOne 2013
CamelOne
Scaling Networks of Brokers
â˘âŻ Brokers share routing information across networks
â˘âŻ All destinations are considered Global
â˘âŻ This is really convenient
â˘âŻ Though it starts to get problematic with 1000âs of
brokers
â˘âŻ However â we can do ďŹltering to shape the trafďŹc
across networks
â˘âŻ But this involves a lot of manual conďŹguration
36
ď crikey!
ď
ď
ď
37. CamelOne 2013
CamelOne
â˘âŻ Brokers share routing information across networks
â˘âŻ All destinations are considered Global
â˘âŻ This is really convenient
â˘âŻ Though it starts to get problematic with 1000âs of
brokers
â˘âŻ However â we can do ďŹltering to shape the trafďŹc
across networks
â˘âŻ But this involves a lot of manual conďŹguration
37
Time to talk about
Apache Camel âŚ
Scaling Networks of Brokers
39. CamelOne 2013
CamelOne
39
ActiveMQ with embedded Camel
beans
  broker brokerName=testBroker  xmlns=http://activemq.apache.org/schema/core
   transportConnectors
    transportConnector uri=tcp://localhost:61616/
   /transportConnectors
  /broker
  import resource=camel.xml/
/beans
Import Camel into ActiveMQ broker config:
40. CamelOne 2013
CamelOne
40
Setup Camel Context in the
usual way
beans
âŚ
camelContext id=camel xmlns=http://camel.apache.org/schema/spring
route
descriptionExample Camel Route/description
from uri=activemq:topic:audio/
setHeader headerName=JMS_AMQP_MESSAGE_FORMAT
constant0/constant
/setHeader
to uri=activemq:queue:audio/
/route
/camelContext
âŚ
/beans
41. CamelOne 2013
CamelOne
Scaling Networks â use Apache Camel
â˘âŻ Allows for non-chatty networks to be
established
â˘âŻ Routing information can be externalized to
the broker
â˘âŻ Successfully used in production for 1000âs
of brokers today
41
43. CamelOne 2013
CamelOne
Problems â Deploying and
maintenance
â˘âŻ Main problems
â˘âŻ Installing brokers on multiple hosts
â˘âŻ ssh, untar, set directories and environment
â˘âŻ Setting conďŹguration manually for every broker
â˘âŻ copying xml conďŹg, tweaking, testing
â˘âŻ Updating conďŹguration across cluster
â˘âŻ Upgrading brokers
Itâs a tedious and error-prone process
44. CamelOne 2013
CamelOne
Problems â Traditional best-
practice tips
â˘âŻ Keep XML as a template and conďŹgure node-speciďŹc
details through properties
â˘âŻ Keep conďŹguration in SVC system (git, svn, ...)
â˘âŻ Keep conďŹguration separate from installation for
easier upgrades
Deployment with Fuse Fabric moves it to the next
level
45. CamelOne 2013
CamelOne
Problems - Clients
â˘âŻ Topology is very âstaticâ
â˘âŻ Clients need to be aware of topology
â˘âŻ Clients need to know broker locations
â˘âŻ Changes are not easy as clients need to be updated
â˘âŻ Adding new resources (brokers) requires client updates
â˘âŻ Not suitable for âcloudâ deployments
Fuse Fabric makes deployments more âelasticâ
47. CamelOne 2013
CamelOne
Fuse Fabric â Key Features
Fuse
 IDE
Â
 hawCo
Â
ActiveMQ
Cluster
Camel
Endpoints
ServiceMix
Runtime
Registry
â˘âŻ Supports Hybrid deployments
â˘âŻ Distributed ConďŹguration
â˘âŻ Runtime registry
â˘âŻ Centralized Management
48. CamelOne 2013
CamelOne
FuseMQ features
â˘âŻ mq-base proďŹle
â˘âŻ DeďŹnes OSGi features and bundles to be installed
â˘âŻ DeďŹnes basic broker settings
â˘âŻ mq-create command
â˘âŻ Helper command for creating brokers
â˘âŻ Creates an new proďŹle based on mq-base
â˘âŻ Optionally creates new containers
â˘âŻ Assigns the proďŹle to containers (essentially starts the broker)
FuseMQ = ActiveMQ deployed in Apache Karaf +
49. CamelOne 2013
CamelOne
Why is Integration and
Messaging Important ?
Head Office
Enterprises
Need to
know
Everything!
51. CamelOne 2013
CamelOne
The Internet of Things
â˘âŻ Uniquely identiďŹable objects and their virtual
representations in an internet-like structure
â˘âŻ Originally deďŹned by Kevin Ashton, co-founder of
Auto-ID center at MIT
â˘âŻ Today its meaning has evolved to encompass a
world where physical objects are integrated into the
information network, and where physical objects
participate in business processes.
51
52. CamelOne 2013
CamelOne
Machine to Machine
â˘âŻ M2M involves collection and transmission of event
level data (used to be called telemetry) from
intelligent devices
â˘âŻ Machines can interact over the net â and/or
attached networks â by wired and wireless
networks
â˘âŻ Payloads are typically minimal (temperature,
pressure, location, metering etc.)
52
53. CamelOne 2013
CamelOne
Internet of Things
Time
Â
Connected
 Devices
 on
 the
Â
internet
Â
2010
 2000
 2020
Â
1
 Billion
Â
50
 Billion
Â
10
Â
 Billion
Â
Ubiquitous
Â
posiConing
 â
Â
locaCng
 people
 and
Â
everyday
 objects
Â
Â
RFID
 tags
 for
Â
Inventory
 control
Â
Advanced
 sensors,
Â
Enterprises
 fully
Â
connected:
 integraCon
Â
of
 everything
Â
Geo-Ââlocated
 devices
Â
Microcontrollers
Â
internet
 enabled
Â
Vending
 machines,
 lone
Â
workers,
 POS,
 vehicles,
Â
planes,
 tolls,
 power
Â
systems,
 transport,
Â
telemedicine,
Â
 home
Â
appliances,
 power
Â
systems,
 etc.
Â
54. CamelOne 2013
CamelOne
M2M Examples
â˘âŻ Smart Energy â
Smart Grid uses smart meters for monitoring energy uses by premises for billing,
substation and transmission line monitoring, energy production (renewables)
â˘âŻ Inventory Control â
smart labels and RFID tags â connected scanners pass information upstream to
servers for monitoring
â˘âŻ In-Vehicle Systems
Maintenance information, global positioning, âblack-boxâ (speed and driving
habits), wireless payments for tolls/gas
â˘âŻ Environmental Monitoring
Weather stations (temperature, air-pressure), ocean monitors, earth
movements, volcanic activity crop yields etc.
â˘âŻ Livestock monitoring
Cow herds, monitored for optimum time for milking, sheep herds for location
54
56. CamelOne 2013
CamelOne
Power Consumption!
â˘âŻ Battery life for mobiles, power consumption for
smart devices is an important consideration.
â˘âŻ Facebook use MQTT for real-time updates â
efďŹciency was one of the things considered
â˘âŻ MQTT is more efďŹcient at establishing connections,
sends information more reliably, and consumes less
power to transmit data than HTTP.
56
57. CamelOne 2013
CamelOne
Deluge of Data
â˘âŻ Billions of devices send information will require
storage and processing of terabytes or even
petabytes of data.
â˘âŻ Big Data Ingestion: Processing of vast amounts of
data business generates to make good decisions is
only half the problem. Ingesting that data from all
areas of the enterprise will require TBs of data to be
ingested in highly reliable and scalable way.
57
58. CamelOne 2013
CamelOne
Need an Eco system of technologies
Dev
â˘âŻ Integration is getting harder
â˘âŻ Traditional message brokers are
key to connect âeverythingâ
â˘âŻ Multiple protocols need to be
supported
â˘âŻ Camel can provide integration at
the edges â and the data center
â˘âŻ Technologies like Fuse Fabric
provide centralized provisioning and
management
â˘âŻ Need to mix protocols, brokers and
âmessage routersâ to scale
FuseMQ
Clusters
Arrival
Airport 1
60. CamelOne 2013
CamelOne
Messaging through the Internet of
Things
ActiveMQ
AMQP/MQTT
routers
AMQP/MQTT
routers
AMQP/MQTT
routers
MQTT
Â
MQTT-ÂâS
Â
AMQP
Â
AMQP
Â
AMQP
Â
MQTT
Â
MQTT
Â
websockets
Â
62. CamelOne 2013
CamelOne
What is Arduino ?
â˘âŻ Open Source Hardware microcontroller
â˘âŻ Cheap and easily available.
â˘âŻ Open Source Software.
â˘âŻ Widespread: many projects.
â˘âŻ Extra HW (shields) available (e.g. WiFi shield)
63. CamelOne 2013
CamelOne
63
Â
USB
7-12 v
3 v GRD 5 v Analog Input Pins
Digital Input/Output Pins
Pins with ~ are PWM
[Analog Output]
GRD
Transmitter/Receiver
Serial Connection
Microcontroller ATmega328
OperatingVoltage 5V
InputVoltage (recommended)7-12V
InputVoltage (limits)6-20V
Digital I/O Pins 14
(of which 6 provide PWM output)
Analog Input Pins 6
DC Current per I/O Pin 40 mA
DC Current for 3.3V Pin 50 mA
64. CamelOne 2013
CamelOne
Arduino Programming
â˘âŻ 3 types of memory on Arduino
â˘âŻ Flash memory (program space) â 32 Kb
â˘âŻ SRAM â used by sketches â 2 Kb
â˘âŻ EPROM â long term memory â 1 Kb
â˘âŻ Programming language based on Wiring: C/C++ library
designed to make input/output easier. Programs are
called sketches.
â˘âŻ Arduino has a simple IDE, available on Windows, Linux
and Mac
65. CamelOne 2013
CamelOne
Arduino MQTT to WebSockets
Arduino
AMQP
Â
MQTT
Â
ActiveMQ
MQTT/AMQP
Gateway
ActiveMQ
AMQP/WebSockets
Broker
HTML 5/WebSockets