1. CamelOne 2013
June 10-11 2013
Boston, MA
Apache ActiveMQ
Internals
Christian Posta
Senior Consultant and Architect
June 10, 2013
1
2. CamelOne 2013
CamelOne
2
Why are You Here?
• Use ActiveMQ?
• What is ActiveMQ?
• Dug into the code?
• Interested in contributing back?
• Understand configuration better
3. CamelOne 2013
CamelOne
3
Goals of Presentation
• Give back to community
• Deliver understanding about architecture
• Brief intro to ActiveMQ
• Overview of architecture
• Dive into major subcomponents
4. CamelOne 2013
CamelOne
4
Who am I?
• Senior Consultant and Architect at Red Hat (formerly
FuseSource)
• Committer on ActiveMQ
• Author: Essential Camel Components DZone Refcard
• Christian Posta
• Blog: http://christianposta.com/blog
• Email: ceposta@apache.org
• Twitter: @christianposta
5. CamelOne 2013
CamelOne
5
What is ActiveMQ?
• OpenSource messaging broker
• Apache v2 licensed
• Very active community
• Used at top companies
• 5.8.0 latest release (in JBoss A-MQ 6.0)
5.9.0 on its way
7. CamelOne 2013
CamelOne
7
When to use ActiveMQ?
• Asynchronous communication
• Reliable message passing
• Loose coupling
• Heterogeneous integration
• Real-time data
9. CamelOne 2013
CamelOne
9
How it’s built
• Java project (supports Java 7!)
• Maven project
• Divided into client/broker and feature modules
• Unit tests in activemq-unit-tests
• mvn
clean
package
–Dtest=false
10. CamelOne 2013
CamelOne
10
ActiveMQ Source
• SVN at Apache: https://svn.apache.org/repos/asf/
activemq/trunk/
• Git at Apache:
http://git.apache.org
• Github:
https://github.com/apache/activemq
• Use git-svn and point directly to Apache SVN!
14. CamelOne 2013
CamelOne
14
Transport Connector
• Let data in or out
• Think of as “SocketServer” (which it is J)
• Broker side
• Highly configurable through URI
• TransportConnector vs Transport
17. CamelOne 2013
CamelOne
17
Wire Formats
• Part of transport
• Encode/marshall
• Decode/unmarshall
• Creates Java objects
Wire
Broker
Transport
Wire
Format
Socket
23. CamelOne 2013
CamelOne
23
Region Broker
• Core of the broker
• Create consumers
• Create producers
• Create destinations
• Send messages to
correct destination
RegionBroker
Router
Topic Region
TempTopic
Region
Queue
Region
TempQueue
Region
Connection
States
Destinations ClientIDs
24. CamelOne 2013
CamelOne
24
Broker Filters
• Decorate RegionBroker
• How internal features like advisories and scheduling
are implemented
• Basis for broker plugins
• http://activemq.apache.org/interceptors.html
• http://activemq.apache.org/developing-plugins.html
38. CamelOne 2013
CamelOne
38
Lockers
• Used for master election
• SharedFileLocker
• DatabaseLocker, LeaseDatabaseLocker
• ZooKeeper based for replicated LevelDB
new in upcoming 5.9.0, not available yet
• Your own!
39. CamelOne 2013
CamelOne
39
Message Stores
• Topic vs Queue stores
• Difference use cases
• Storage vs broadcast
• Relatively cheap
Topic Store
Topic Store
Topic Store
Journal
Index Redo
File System
Queue Store
Queue Store
Queue Store