AMQP with RabbitMQ

Information about AMQP with RabbitMQ

Published on June 8, 2016

Author: SpyrosPapageorgiou1



1. AMQP with RabbitMQ Using Spring and Camel

2. Kosmas Kyriakidis: LinkedIn Spyros Papageorgiou: LinkedIn, GitHub ● Software Engineers at A.M.D Telecom S.A ● We develop: ○ A new communication platform to provide communication as a service ● We do: ○ Agile Development ○ Continuous Integration ○ Continuous Deployment ○ Unit Testing Who we are

3. ● Why Messaging, ● AMQP Overview ● RabbitMQ ● AMQP Basics ● AMQP with Spring/Camel Overview

4. Messaging ● Messaging provides a mechanism for loosely-coupled integration of systems ● The central unit of processing is a message which typically contains a body and a header ● Messaging solutions provide means for: ○ securing message transfer, authenticating and authorizing messaging endpoints ○ subscribing to the broker ○ routing messages between endpoints ● Use cases include: ○ Log aggregation between systems ○ Event propagation between systems ○ Offloading long-running tasks to worker nodes

5. General Messaging Architecture Message Broker Producer Producer Consumer Consumer

6. Why Messaging ● Decoupling ○ Data, no action i.e. receiver can react arbitrarily ○ Asynchronous i.e. decoupled by time ● Reliable ○ Message can be stored and forwarded ○ Redelivery until message processed But: ● Requires different architecture ● Very different from calling remote methods or polling ● Asynchronous

7. AMQP ● Advanced Message Queuing Protocol ● Open standard protocol (Less vendor lock in) ● Standard wire protocol ○ i.e. just one client library – no matter which implementation you are using ● Support in all major languages ● Efficient ○ Binary wire protocol ○ Multiple channels per connection

8. RabbitMQ ● RabbitMQ is an open source message broker software that implements AMQP(0.8, 0.9, 0.9.1) ● Numerous other protocols supported(XMPP, SMTP, ..) ● Foundation for demanding systems e.g. ○ NASA’s cloud initiative Nebula ○ Handles more than 1million msg/s on Google Cloud Compute ● Clustering built in ● Virtual Hosts for security and organization ● Comes with a web management interface ● Currently in 3.6.2

9. RabbitMQ

10. AMQP Basics: Queues ● Store messages / FIFO Queue ● Queues might be: ○ Durable: Survive server restarts ○ Exclusive: For one connection / Autogenerated ○ Auto Deleted: Deleted if connectioncloses ● Queue usually created by consumer ● A message from a Queue goes only to one consumer QUEUE C C

11. AMQP Basics: Exchanges ● Exchange: Route messages (stateless) ● The type of Exchange defines the routing algorithm used ● No queue: Message discarded ● More dynamic, flexible and cleaner than JMS ● Usually created by producer ● A producer sends a messages to an Exchange Exchange P

12. Exchange Types: Direct ● Point to Point communication ● Producer declares exchange ● Consumer declares the queue and binds it to the exchange Direct

13. Exchanges with binding keys ● Binding provides selector for routing messages from exchanges to queues ● Each binding between an exchange and a queue has a binding key ● Each message can be published with a routing key ● Routing of messages is determined based on matching between the routing and binding keys Message Routing Key Headers Message Body Bindings Direct

14. Exchange Types: Fanout ● Broadcast messages ● Routing key is ignored ● Many queues, many consumers ● Broadcast to all bound queues

15. Exchange Types: Topic ● Delivery based on routing key ● Intended for multicast routing ● Messages are published with an explicit routing key ● Consumers use wildcards when binding queues to exchanges ● Supports multiple queues and multiple subscribers Topic

16. Exchange Types: Header ● Similar to Direct but uses headers rather than routing key ● Queues can be bound to an exchange with multiple headers ● Multiple headers may be matched with "any" or "all" Header Name Header Value age 23 name kosmas x-match all

17. Integrating with RabbitMQ using Spring/Camel Apache Camel focuses on making integration easier and more accessible to developers. It does this by providing: ● concrete implementations of all the widely used Enterprise Integration Patterns (EIPs) ● connectivity to a great variety of transports and APIs Maven dependencies you will need ● spring-boot-starter ● camel-spring-boot ● camel-rabbitmq

18. Lets see some code

19. ● RabbitMQ Java tutorials using the official driver ○ ● Camel component for integrating with RabbitMQ ○ ● The code you saw today ○ ● Spring AMQP tutorial using RabbitTemplate ○ Helpful Links

20. Thank you for your time!

Related presentations