SlideShare ist ein Scribd-Unternehmen logo
1 von 30
Java Messaging with
AMQP and RabbitMQ
или “JMS, давай до-свидания”
1
The big picture
2
3
Async Java World
Servlets 3.0 - async requests Servlets 3.1 - nio
Netty ReactiveX (RxJava)
Vert.xJAX-RSSpring MVC
Play Framework Akka
4
Messaging Protocols
AMQP
MQTT
STOMP
0-9-1 1-0
JMS
SMTP, POP3, IMAP
XMPP
DDS
5
Protocols comparison
6
AMQP facts
Wire Protocol
Родился в 2006 in J.P.Morgan (миллиарды сообщений в
день)
Миссия: интеграция сообщений между платформами
Поддерживается в Apache Camel, Spring Integration, Mule,..
7
AMQP is the Internet Protocol for Business
Messaging
versions:
1.0 - Now International standard:
ISO/IEC 19464:2014, OASIS (2014)
RabbitMQ supports version 1.0 via plugin
0-10, 0-9-1, 0-9, 0-8
1.0:
Not declaring broker architecture, broker management
commands. Symmetric.
8
9
Frames
Frame structure:
Sending content:
Content Header:
10
One Million Messages Per Second on Google
31 nodes, 8 virtual CPUs on each, 248 cores total
(2014, https://blog.pivotal.io/pivotal/products/rabbitmq-hits-one-million-messages-per-second-on-google-
compute-engine
11
JMS
AMQP
12
Exchange
Direct Fanout Topic Headers
Types:
Features:
• Durability (survive broker restart)
• Auto-delete (deleted when all queues have finished using it)
Default Exchange
13
14
15
Topic Exchange
* (star) can substitute for exactly one word.
# (hash) can substitute for zero or more words.
16
More Exchange Types
• Headers - по заголовкам сообщения “x-
match”=“any”/“all”
• Dead Letter Exchange (для недоставленных
сообщений)
• Constant-Hash (plugin)
• Delayed Exchange ( задержки перед отправкой)
• more …
17
Queues
• FIFO (soft)
• Durable / in-memory
• Exclusive
• Auto-delete
• Arguments (TTL,…)
18
Consumers
• Rule: One message goes to one consumer, unless redelivery
happens
• Serial per Channel (thread)
• Pull / Subscribe API
• Send acknowledgements (ack)
• can do “auto-ack” ( hits reliability )
• round robin with optional priorities
19
20
21
Что у кролика внутри
Erlang
• создан в Ericsson для телеком-железа
• functional
• lightweight processes
• good scaling over CPU
• deadlocks-aware design
• communication between network-distributed processes
• Live code upgrade
• Built in Process Monitoring and Control
22
Concurrency
23
Spring
@Bean
public ConnectionFactory connectionFactory() {
CachingConnectionFactory cf = new CachingConnectionFactory("localhost");
cf.setUsername("guest");
cf.setPassword("guest");
return cf;
}
@Bean
public AmqpAdmin amqpAdmin() {
return new RabbitAdmin(connectionFactory());
}
@Bean
public RabbitTemplate rabbitTemplate() {
RabbitTemplate template = new RabbitTemplate(connectionFactory());
// Отправлять сюда
template.setRoutingKey(this.helloWorldQueueName);
// Чиать отсюда
template.setQueue(this.helloWorldQueueName);
return template;
}
24
Spring async consume
@Bean
public SimpleMessageListenerContainer listenerContainer() {
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
container.setConnectionFactory(connectionFactory());
container.setQueueNames(this.helloWorldQueueName);
container.setMessageListener(new MessageListenerAdapter(new HelloWorldHandler()));
return container;
}
Sync:
AmqpTemplate amqpTemplate = context.getBean(AmqpTemplate.class);
System.out.println("Received: " + amqpTemplate.receiveAndConvert());
25
Spring: ListenerContainer
AbstractMessageListenerContainer
private volatile Object messageListener;
private volatile AcknowledgeMode acknowledgeMode = AcknowledgeMode.AUTO;
private MessageConverter messageConverter;
private ErrorHandler errorHandler = new ConditionalRejectingErrorHandler();
…
SimpleMessageListenerContainer
private volatile Executor taskExecutor = new SimpleAsyncTaskExecutor();
private volatile int concurrentConsumers = 1;
private volatile Integer maxConcurrentConsumers;
private volatile boolean exclusive;
private volatile int prefetchCount = DEFAULT_PREFETCH_COUNT; // 1
…
26
RabbitTemplate
currently, the only implementation of AMQPTemplate
Methods:
send(Message m, …), convertAndSend(Object o , …) …
recieve(): Message, recieveAndConvert(…), recieveAndReply(…) …
sendAndRecieve(…), convertSendAndRecieve(), …
Features:
• Retry and recovery (spring-retry)
• Publisher confirms and returns (ReturnCallback, ConfirmCallback)
• Message PostProcessors - after receive and before publish (zip/unzip, …)
27
Finally, AMQP vs JMS
JMS
Standard API
Native to Java world
Enterprizzy
AMQP
Truly Cross - platform
Comprehensive Topology
More Tuning (?)
Some Readings:
“Understanding the differences between AMQP and JMS”
http://www.wmrichards.com/amqp.pdf
Why Erlang is good for AMQP implementation
https://pubs.vmware.com/vfabric5/index.jsp#com.vmware.vfabric.rabbitmq.2.4/erlang.html
Alvaro Videla’s presentation “RabbitMQ Internal Architecture”
http://www.slideshare.net/old_sound/dissecting-the-rabbit
All About Messaging Protocols. What Are the Differences? by Bryon Moyer
http://www.eejournal.com/archives/articles/20150420-protocols/
Whats wrong with AMQP and how to fix it
http://www.imatix.com/articles:whats-wrong-with-amqp/
Messaging Products performance comparison
https://softwaremill.com/mqperf/
Thanks
Sincerely Yours,
Maxim Konovalov
BPC Banking Technologies, Runet Business Systems
https://www.facebook.com/maxim.konovalov.1

Weitere ähnliche Inhalte

Was ist angesagt?

XMPP & AMQP
XMPP & AMQPXMPP & AMQP
XMPP & AMQP
voluntas
 

Was ist angesagt? (20)

AMQP with RabbitMQ
AMQP with RabbitMQAMQP with RabbitMQ
AMQP with RabbitMQ
 
The RabbitMQ Message Broker
The RabbitMQ Message BrokerThe RabbitMQ Message Broker
The RabbitMQ Message Broker
 
RabbitMQ & Hutch
RabbitMQ & HutchRabbitMQ & Hutch
RabbitMQ & Hutch
 
Messaging Standards and Systems - AMQP & RabbitMQ
Messaging Standards and Systems - AMQP & RabbitMQMessaging Standards and Systems - AMQP & RabbitMQ
Messaging Standards and Systems - AMQP & RabbitMQ
 
Messaging Standards and Systems - AMQP & RabbitMQ
Messaging Standards and Systems - AMQP & RabbitMQMessaging Standards and Systems - AMQP & RabbitMQ
Messaging Standards and Systems - AMQP & RabbitMQ
 
AMQP for phpMelb
AMQP for phpMelbAMQP for phpMelb
AMQP for phpMelb
 
[@NaukriEngineering] Messaging Queues
[@NaukriEngineering] Messaging Queues[@NaukriEngineering] Messaging Queues
[@NaukriEngineering] Messaging Queues
 
XMPP & AMQP
XMPP & AMQPXMPP & AMQP
XMPP & AMQP
 
An update from the RabbitMQ team - Michael Klishin
An update from the RabbitMQ team - Michael KlishinAn update from the RabbitMQ team - Michael Klishin
An update from the RabbitMQ team - Michael Klishin
 
A walk-through of the design and architecture of RabbitMQ - Ayanda Dube
A walk-through of the design and architecture of RabbitMQ - Ayanda DubeA walk-through of the design and architecture of RabbitMQ - Ayanda Dube
A walk-through of the design and architecture of RabbitMQ - Ayanda Dube
 
Messaging with RabbitMQ and AMQP
Messaging with RabbitMQ and AMQPMessaging with RabbitMQ and AMQP
Messaging with RabbitMQ and AMQP
 
Spring RabbitMQ
Spring RabbitMQSpring RabbitMQ
Spring RabbitMQ
 
Distributed messaging with AMQP
Distributed messaging with AMQPDistributed messaging with AMQP
Distributed messaging with AMQP
 
Amqp Basic
Amqp BasicAmqp Basic
Amqp Basic
 
Integrating PostgreSql with RabbitMQ
Integrating PostgreSql with RabbitMQIntegrating PostgreSql with RabbitMQ
Integrating PostgreSql with RabbitMQ
 
Introduction To RabbitMQ
Introduction To RabbitMQIntroduction To RabbitMQ
Introduction To RabbitMQ
 
A Closer Look at RabbitMQ
A Closer Look at RabbitMQA Closer Look at RabbitMQ
A Closer Look at RabbitMQ
 
Messaging with amqp and rabbitmq
Messaging with amqp and rabbitmqMessaging with amqp and rabbitmq
Messaging with amqp and rabbitmq
 
RabbitMQ fairly-indepth
RabbitMQ fairly-indepthRabbitMQ fairly-indepth
RabbitMQ fairly-indepth
 
Scaling application with RabbitMQ
Scaling application with RabbitMQScaling application with RabbitMQ
Scaling application with RabbitMQ
 

Andere mochten auch

HornetQ Presentation On JBoss World 2009
HornetQ Presentation On JBoss World 2009HornetQ Presentation On JBoss World 2009
HornetQ Presentation On JBoss World 2009
jarfield
 

Andere mochten auch (9)

Differences between JMS and AMQP
Differences between JMS and AMQPDifferences between JMS and AMQP
Differences between JMS and AMQP
 
HornetQ Presentation On JBoss World 2009
HornetQ Presentation On JBoss World 2009HornetQ Presentation On JBoss World 2009
HornetQ Presentation On JBoss World 2009
 
Web sphere mq Online Training at bigclasses
Web sphere mq Online Training at bigclassesWeb sphere mq Online Training at bigclasses
Web sphere mq Online Training at bigclasses
 
Interoperability With RabbitMq
Interoperability With RabbitMqInteroperability With RabbitMq
Interoperability With RabbitMq
 
RabbitMQ Data Ingestion at Craft Conf
RabbitMQ Data Ingestion at Craft ConfRabbitMQ Data Ingestion at Craft Conf
RabbitMQ Data Ingestion at Craft Conf
 
Ibm web sphere application server interview questions
Ibm web sphere application server interview questionsIbm web sphere application server interview questions
Ibm web sphere application server interview questions
 
RabbitMQ Data Ingestion
RabbitMQ Data IngestionRabbitMQ Data Ingestion
RabbitMQ Data Ingestion
 
IBM WebSphere MQ Introduction
IBM WebSphere MQ Introduction IBM WebSphere MQ Introduction
IBM WebSphere MQ Introduction
 
REST vs. Messaging For Microservices
REST vs. Messaging For MicroservicesREST vs. Messaging For Microservices
REST vs. Messaging For Microservices
 

Ähnlich wie Java Messaging with AMQP and RabbitMQ

quickguide-einnovator-3-rabbitmq
quickguide-einnovator-3-rabbitmqquickguide-einnovator-3-rabbitmq
quickguide-einnovator-3-rabbitmq
jorgesimao71
 
Building scalable network applications with Netty
Building scalable network applications with NettyBuilding scalable network applications with Netty
Building scalable network applications with Netty
NLJUG
 
LLVM-based Communication Optimizations for PGAS Programs
LLVM-based Communication Optimizations for PGAS ProgramsLLVM-based Communication Optimizations for PGAS Programs
LLVM-based Communication Optimizations for PGAS Programs
Akihiro Hayashi
 
Apache Kafka
Apache KafkaApache Kafka
Apache Kafka
Joe Stein
 
Flink Streaming Hadoop Summit San Jose
Flink Streaming Hadoop Summit San JoseFlink Streaming Hadoop Summit San Jose
Flink Streaming Hadoop Summit San Jose
Kostas Tzoumas
 
Messaging for Web and Mobile with Apache ActiveMQ
Messaging for Web and Mobile with Apache ActiveMQMessaging for Web and Mobile with Apache ActiveMQ
Messaging for Web and Mobile with Apache ActiveMQ
dejanb
 

Ähnlich wie Java Messaging with AMQP and RabbitMQ (20)

EIP In Practice
EIP In PracticeEIP In Practice
EIP In Practice
 
Chicago Kafka Meetup
Chicago Kafka MeetupChicago Kafka Meetup
Chicago Kafka Meetup
 
quickguide-einnovator-3-rabbitmq
quickguide-einnovator-3-rabbitmqquickguide-einnovator-3-rabbitmq
quickguide-einnovator-3-rabbitmq
 
Building scalable network applications with Netty
Building scalable network applications with NettyBuilding scalable network applications with Netty
Building scalable network applications with Netty
 
Building scalable network applications with Netty (as presented on NLJUG JFal...
Building scalable network applications with Netty (as presented on NLJUG JFal...Building scalable network applications with Netty (as presented on NLJUG JFal...
Building scalable network applications with Netty (as presented on NLJUG JFal...
 
Apache Kafka - Scalable Message Processing and more!
Apache Kafka - Scalable Message Processing and more!Apache Kafka - Scalable Message Processing and more!
Apache Kafka - Scalable Message Processing and more!
 
LLVM-based Communication Optimizations for PGAS Programs
LLVM-based Communication Optimizations for PGAS ProgramsLLVM-based Communication Optimizations for PGAS Programs
LLVM-based Communication Optimizations for PGAS Programs
 
Apache Kafka
Apache KafkaApache Kafka
Apache Kafka
 
Flink Streaming Hadoop Summit San Jose
Flink Streaming Hadoop Summit San JoseFlink Streaming Hadoop Summit San Jose
Flink Streaming Hadoop Summit San Jose
 
Apache Flink(tm) - A Next-Generation Stream Processor
Apache Flink(tm) - A Next-Generation Stream ProcessorApache Flink(tm) - A Next-Generation Stream Processor
Apache Flink(tm) - A Next-Generation Stream Processor
 
Down the RabbitMQ Hole
Down the RabbitMQ HoleDown the RabbitMQ Hole
Down the RabbitMQ Hole
 
Flexible and Real-Time Stream Processing with Apache Flink
Flexible and Real-Time Stream Processing with Apache FlinkFlexible and Real-Time Stream Processing with Apache Flink
Flexible and Real-Time Stream Processing with Apache Flink
 
Splunk Conf 2014 - Getting the message
Splunk Conf 2014 - Getting the messageSplunk Conf 2014 - Getting the message
Splunk Conf 2014 - Getting the message
 
Apache Tomcat 7 by Filip Hanik
Apache Tomcat 7 by Filip HanikApache Tomcat 7 by Filip Hanik
Apache Tomcat 7 by Filip Hanik
 
StrongLoop Overview
StrongLoop OverviewStrongLoop Overview
StrongLoop Overview
 
Introduction to Kafka Streams
Introduction to Kafka StreamsIntroduction to Kafka Streams
Introduction to Kafka Streams
 
Implementing an IPv6 Enabled Environment for a Public Cloud Tenant
Implementing an IPv6 Enabled Environment for a Public Cloud TenantImplementing an IPv6 Enabled Environment for a Public Cloud Tenant
Implementing an IPv6 Enabled Environment for a Public Cloud Tenant
 
Architecture | The Future of Messaging: RabbitMQ and AMQP | Eberhard Wolff
Architecture | The Future of Messaging: RabbitMQ and AMQP | Eberhard WolffArchitecture | The Future of Messaging: RabbitMQ and AMQP | Eberhard Wolff
Architecture | The Future of Messaging: RabbitMQ and AMQP | Eberhard Wolff
 
Dataservices: Processing Big Data the Microservice Way
Dataservices: Processing Big Data the Microservice WayDataservices: Processing Big Data the Microservice Way
Dataservices: Processing Big Data the Microservice Way
 
Messaging for Web and Mobile with Apache ActiveMQ
Messaging for Web and Mobile with Apache ActiveMQMessaging for Web and Mobile with Apache ActiveMQ
Messaging for Web and Mobile with Apache ActiveMQ
 

Kürzlich hochgeladen

Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 

Kürzlich hochgeladen (20)

Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 

Java Messaging with AMQP and RabbitMQ

  • 1. Java Messaging with AMQP and RabbitMQ или “JMS, давай до-свидания” 1
  • 3. 3
  • 4. Async Java World Servlets 3.0 - async requests Servlets 3.1 - nio Netty ReactiveX (RxJava) Vert.xJAX-RSSpring MVC Play Framework Akka 4
  • 7. AMQP facts Wire Protocol Родился в 2006 in J.P.Morgan (миллиарды сообщений в день) Миссия: интеграция сообщений между платформами Поддерживается в Apache Camel, Spring Integration, Mule,.. 7
  • 8. AMQP is the Internet Protocol for Business Messaging versions: 1.0 - Now International standard: ISO/IEC 19464:2014, OASIS (2014) RabbitMQ supports version 1.0 via plugin 0-10, 0-9-1, 0-9, 0-8 1.0: Not declaring broker architecture, broker management commands. Symmetric. 8
  • 9. 9
  • 11. One Million Messages Per Second on Google 31 nodes, 8 virtual CPUs on each, 248 cores total (2014, https://blog.pivotal.io/pivotal/products/rabbitmq-hits-one-million-messages-per-second-on-google- compute-engine 11
  • 13. Exchange Direct Fanout Topic Headers Types: Features: • Durability (survive broker restart) • Auto-delete (deleted when all queues have finished using it) Default Exchange 13
  • 14. 14
  • 15. 15
  • 16. Topic Exchange * (star) can substitute for exactly one word. # (hash) can substitute for zero or more words. 16
  • 17. More Exchange Types • Headers - по заголовкам сообщения “x- match”=“any”/“all” • Dead Letter Exchange (для недоставленных сообщений) • Constant-Hash (plugin) • Delayed Exchange ( задержки перед отправкой) • more … 17
  • 18. Queues • FIFO (soft) • Durable / in-memory • Exclusive • Auto-delete • Arguments (TTL,…) 18
  • 19. Consumers • Rule: One message goes to one consumer, unless redelivery happens • Serial per Channel (thread) • Pull / Subscribe API • Send acknowledgements (ack) • can do “auto-ack” ( hits reliability ) • round robin with optional priorities 19
  • 20. 20
  • 21. 21
  • 22. Что у кролика внутри Erlang • создан в Ericsson для телеком-железа • functional • lightweight processes • good scaling over CPU • deadlocks-aware design • communication between network-distributed processes • Live code upgrade • Built in Process Monitoring and Control 22
  • 24. Spring @Bean public ConnectionFactory connectionFactory() { CachingConnectionFactory cf = new CachingConnectionFactory("localhost"); cf.setUsername("guest"); cf.setPassword("guest"); return cf; } @Bean public AmqpAdmin amqpAdmin() { return new RabbitAdmin(connectionFactory()); } @Bean public RabbitTemplate rabbitTemplate() { RabbitTemplate template = new RabbitTemplate(connectionFactory()); // Отправлять сюда template.setRoutingKey(this.helloWorldQueueName); // Чиать отсюда template.setQueue(this.helloWorldQueueName); return template; } 24
  • 25. Spring async consume @Bean public SimpleMessageListenerContainer listenerContainer() { SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); container.setConnectionFactory(connectionFactory()); container.setQueueNames(this.helloWorldQueueName); container.setMessageListener(new MessageListenerAdapter(new HelloWorldHandler())); return container; } Sync: AmqpTemplate amqpTemplate = context.getBean(AmqpTemplate.class); System.out.println("Received: " + amqpTemplate.receiveAndConvert()); 25
  • 26. Spring: ListenerContainer AbstractMessageListenerContainer private volatile Object messageListener; private volatile AcknowledgeMode acknowledgeMode = AcknowledgeMode.AUTO; private MessageConverter messageConverter; private ErrorHandler errorHandler = new ConditionalRejectingErrorHandler(); … SimpleMessageListenerContainer private volatile Executor taskExecutor = new SimpleAsyncTaskExecutor(); private volatile int concurrentConsumers = 1; private volatile Integer maxConcurrentConsumers; private volatile boolean exclusive; private volatile int prefetchCount = DEFAULT_PREFETCH_COUNT; // 1 … 26
  • 27. RabbitTemplate currently, the only implementation of AMQPTemplate Methods: send(Message m, …), convertAndSend(Object o , …) … recieve(): Message, recieveAndConvert(…), recieveAndReply(…) … sendAndRecieve(…), convertSendAndRecieve(), … Features: • Retry and recovery (spring-retry) • Publisher confirms and returns (ReturnCallback, ConfirmCallback) • Message PostProcessors - after receive and before publish (zip/unzip, …) 27
  • 28. Finally, AMQP vs JMS JMS Standard API Native to Java world Enterprizzy AMQP Truly Cross - platform Comprehensive Topology More Tuning (?)
  • 29. Some Readings: “Understanding the differences between AMQP and JMS” http://www.wmrichards.com/amqp.pdf Why Erlang is good for AMQP implementation https://pubs.vmware.com/vfabric5/index.jsp#com.vmware.vfabric.rabbitmq.2.4/erlang.html Alvaro Videla’s presentation “RabbitMQ Internal Architecture” http://www.slideshare.net/old_sound/dissecting-the-rabbit All About Messaging Protocols. What Are the Differences? by Bryon Moyer http://www.eejournal.com/archives/articles/20150420-protocols/ Whats wrong with AMQP and how to fix it http://www.imatix.com/articles:whats-wrong-with-amqp/ Messaging Products performance comparison https://softwaremill.com/mqperf/
  • 30. Thanks Sincerely Yours, Maxim Konovalov BPC Banking Technologies, Runet Business Systems https://www.facebook.com/maxim.konovalov.1