Do we need JMS in
21st century?
Mikalai Alimenkou
http://xpinjection.com
@xpinjection
Disclaimer
This is all my
personal experience
Modern #NOJMS religion
(Not Only JMS)
JMS is very old but still rocks
JMS 1.1 was over-abstraction
JMS 2.0 brings fresh breeze
Brokers have tons of features!
• Point-to-point messaging
• Publish/subscribe
• Request/reply messaging
• Message persistence
• Message prioritization
• Message routing
• Message types
• JMS transactions
• XA transactions
• Scalability
• Redelivery policies
• Async sends
• Delays and scheduling
• Destination policies
• Slow consumers
• Message selectors
• Exclusive consumer
• Virtual destinations
• Message groups
• REST API
Complexity brings pain…
#1. There are no lost messages
Default config looses messages
• Non persistent messages
• No transactions on both sides
• No wait for ACK on producer side
• AUTO ACK on consumer side
• No flush on disc on every write
Message persistence is hard
“Features” make it even harder
Ultra performance by default
100x slower in realistic cases
ActiveMQ looses messages
HornetQ looses messages
#2. Duplicates are impossible
Duplicates detection works well
Special header
with unique ID
for each
message
Page out
message once,
redelivery
policies
Check if
redelivered,
constraints
But not always possible…
• The JMS transaction starts
• The destination object receives the message
• The DB transaction starts
• The DB stores the message
• Now since DB activity is over, DB transaction commits
• Now due to some reason, the JMS transaction fails and the
transaction is roll-backed.
But not always possible…
• The JMS transaction starts
• The destination object receives the message
• The DB transaction starts
• The DB stores the message
• Now since DB activity is over, DB transaction commits
• Now due to some reason, the JMS transaction fails and the
transaction is roll-backed.
May be use XA
transactions?
But not always possible…
• The JMS transaction starts
• The destination object receives the message
• The DB transaction starts
• The DB stores the message
• Now since DB activity is over, DB transaction commits
• Now due to some reason, the JMS transaction fails and the
transaction is roll-backed.
May be use XA
transactions?
Optimist-style development
OMG!?! HOW DID I
USE IT BEFORE?
Why do you send a message?
• Are consumers local?
• Do you run you app on a single node or distributed?
• Could you restore all messages from app state on restart?
• How many messages are you going to send?
• Are you restricted in technology choice?
• Is it critical if a message is lost?
JMS or not JMS?
This is a question!
Welcome to the
“dark side” of
messaging!
http://queues.io
#1. Local BlockingQueue
Simple producer
Simple consumer
Cook it with Apache Camel
Or with Spring Integration
#2. ZooKeeper + Curator
Different implementations
#3. Hazelcast
Embedded cluster message bus
Distributed queues in JDK style
#4. Redis
Lightweight Pub/Sub
Simple producer
Simple consumer
Reliable flexible queues on lists
BUT!
You need enough RAM to
store all messages.
#5. ZeroMQ
Implement simple server
Implement simple worker
#6. AMQP with RabbitMQ
Focused only on key features
• Flexible reliability
• Clustering
• Federation
• Highly available queues
• Multi-protocol
• Clients in different languages
#7. Amazon SQS
Reliable, scalable, cheap!
Has JMS compatible driver…
Reliable, scalable, cheap!
Has JMS compatible driver…
#8. Kafka
Sharded write-ahead log
Always persistent with fault-tolerance. Messages are
immediately written to the filesystem when they are
received.
Data size doesn’t affect speed
Traditional author’s benchmark
Kafka at LinkedIn
 300+ Kafka brokers
 Over 18,000 topics
 140,000+ Partitions
 220 Billion messages per day
 40 Terabytes In
 160 Terabytes Out
Peak Load:
– 3.25 Million messages per
second
– 5.5 Gigabits/sec Inbound
– 18 Gigabits/sec Outbound
Think about what I
told you today and
may be the world
will become a little
bit better…
@xpinjection
http://xpinjection.com
mikalai.alimenkou@xpinjection.com

Do we need JMS in 21st century?