SlideShare ist ein Scribd-Unternehmen logo
1 von 48
Downloaden Sie, um offline zu lesen
The Future of Messaging:
 RabbitMQ and AMQP

           Eberhard Wolff
Architecture & Technology Manager
       adesso AG, Germany
About me
•    Eberhard Wolff
•    Architecture & Technology Manager at adesso
•    adesso is a leading IT consultancy in Germany
•    Speaker
•    Author (i.e. first German Spring book)
•    Blog: http://ewolff.com
•    Twitter: @ewolff
•    eberhard.wolff@adesso.de
Overview
•  Why Messaging, AMQP and RabbitMQ

•  Basic AMQP

•  Advanced AMQP

•  Advanced Spring-AMQP
RPC
•  Predominant approach
  –  RMI, SOAP Web Services, CORBA, HttpInvoker,
     Burlap, Hessian
•  Calls remote methods with parameter
•  …and waits for response
•  Problems:
  –  Explicitly tells the server what to do i.e. tight
     coupling
  –  What about network failures?
  –  What about long latencies?
Why Messaging?
•  Decoupling
  –  Data, no action i.e. receiver
                                     Component
     can react arbitrarily
  –  Asynchronous i.e. decoupled
     by time
•  Reliable
  –  Message can be stored-and-
                                     Component
     forwarded
                                                 Messages
  –  Redelivery until message
     processed
•  Solves typical problems of
   distributed systems
Why Messaging?
•  But: Requires different architecture
•  Very different from calling remote methods
•  Asynchronous

•  AJAX has the same model

•  See for example “Patterns of Enterprise
   Integration”
Why AMQP?
•  Open standard protocol
•  Standard wire protocol
•  i.e. just one client library – no matter which
   implementation you are using
•  Less vendor lock in
•  Efficient
 –  Binary wire protocol
•  Support in all major languages
•  Supported on most OS platforms
What about JMS?
•  JMS has been the default for Java messaging
   system for 10+ years
•  But:
  •  Only standardized on the API level
  •  Less flexible than AMQP
•  Mapping AMQP/JMS is being defined
•  There is
   git://github.com/pieterh/openamq-jms.git
Why Rabbit?
•    Because it has a kewl name
•    Numerous protocols supported
•    Most popular choice on EC2
•    Foundation for demanding systems e.g.
     NASA’s cloud initiative Nebula
•    Implemented in Erlang
•    Clustering built in
•    Currently in 2.4.1
•    Supports AMQP 0.8, 0.9, 0.9.1
Broad Support in RabbitMQ
Broad Support in the JVM Space
•  Grails Plug In
•  Java Client
•  Scala / Lift support

•  We will discuss Spring support in detail
•  Spring AMQP project 1.0.0.RC1
•  http://www.springsource.org/spring-amqp
Why Erlang?
•  Originally designed for telephone
   switches by Ericsson
•  Much easier to develop scalable and fault
   tolerant systems (by factors)
•  See Motorola presentation:
   http://www.slideshare.net/Arbow/comparing-
   cpp-and-erlang-for-motorola-telecoms-
   software
•  Good tool for reliable and scalable systems
Erlang‘s Model
                      Monitor
Link to monitor,
restart



  Light               Light                 Light
  weight    Messages weight     Messages    weight
 process             process               process
   with                with                  with
   state               state                 state
Why Erlang?
•  Let it crash
  –  If a process fails, it can be easily restarted
  –  Different approach to fault tolerance
  –  Otherwise lots of error handling
•  Message Passing in the Core
  –  RabbitMQ is a messaging system…
•  Light-weight process model
  –  Scalabiliy
Very Basic AMQP
•  Queues: Store messages
•  Queues might be
     –  Durable: Survive server restarts
     –  Exclusive: For one connection
     –  autoDelete: Deleted if connection closes
•    Queue usually created by consumer
•    All resources are dynamic
•    Producer sends a message to a Queue
•    Let’s see some code…
Spring’s RabbitTemplate
•  Send & receive message
•  AmqpTemplate: Generic AMQP interface
•  RabbitOperations: Rabbit specific interface:
   (adds just a callback)
•  RabbitTemplate: Implementation
•  Spring might provide support for other AMQP
   implementations later
•  Common interface
Spring’s MessageConverter
•  Messages are binary data
•  RabbitTemplate uses MessageConverter
   to convert between objects and messages
•  Can also send binary data if preferred
•  Default: SimpleMessageConverter
  –  byte[] directly transferred
  –  String converted with configurable encoding
  –  Serializable are serialized
  –  Content type set accordingly
•  JsonMessageConverter converts from / to JSON
   using Jackson
•  MarshallingMessageConverter converts from / to XML
   using Spring's OXM mapping
Spring‘s AdminTemplate
•  Main purpose: Configure the AMQP
   infrastructure
•  E.g. create queues

•  AmpqAdmin: Generic AMQP interface
•  RabbitAdmin: Rabbit specific
Code
ConnectionFactory conFactory =	
   new SingleConnectionFactory("localhost");	
RabbitTemplate template = 	
  new RabbitTemplate(conFactory);	
RabbitAdmin admin = new RabbitAdmin(conFactory);	
	
admin.declareQueue(new Queue("myQueue"));	
	
template.convertAndSend("myQueue", "Hi AMQP!");	
String receive =	
  (String) template.receiveAndConvert("myQueue");	
Assert.assertEquals("Hi AMQP!", receive);
Basics of AMQP
•  Sending messages directly to queues is not
   enough
•  What about e.g. pub / sub?

•  Exchange: Route messages (stateless)
•  Messages are byte-streams
•  Example used the default exchange

•  More dynamic, flexible and cleaner than JMS
AMQP	
  in	
  a	
  nutshell	
  
Exchange routes message
Stateless
Usually created by producer
No queue: Message discarded
           X

               Binding binds an
               Exchange to a Queue    Queues buffer
                                      messages
                                      Usually created by
                                      consumer
AMQP	
  in	
  a	
  nutshell	
  
Producer and Consumer might be written in Java, C#,
Python, Ruby …

                                                      C
        P          X

                                                      C


        AMQP             RabbitMQ               AMQP
        protocol                                protocol
Exchange: Route Messages                  X


•  The type of Exchange defined the routing
   algorithm used
•  Binding provides selector for routing
•  Exchange is addressed by name

•  Some standard types
•  Can provide additional ones
Fanout Exchange         X


•  Broadcast to all bound queues
•  Fast
•  Simple

•  amq.fanout is mandatory

•  To broadcast information
Fanout Exchange       X




                      C
P     X

                      C
    Fanout
                      C
Queue fanoutQueue = new Queue("fanoutQueue");	
admin.declareQueue(fanoutQueue);	
	
FanoutExchange fanoutExchange=	
  new FanoutExchange("myFanout");	
admin.declareExchange(fanoutExchange);	
	
admin.declareBinding(	
  BindingBuilder.from(fanoutQueue).	
                 to(fanoutExchange));	
	
template.setExchange("myFanout");	
template.convertAndSend("Hi Fanout!");	
	
String receive = (String)	
   template.receiveAndConvert("fanoutQueue");	
Assert.assertEquals("Hi Fanout!", receive);
Direct Exchange                   X


•  Routing based on one routing key
•  amq.direct and the default Exchange (no
   name) always exist

•  To send work orders to a specific worker
Direct Exchange

normal
express
          Direct
          Exchange                 C
                     express
   P         X

                                   C
                 normal
                                   C
Queue directQueue = new Queue("direct");	
admin.declareQueue(directQueue);	
	
admin.declareBinding(BindingBuilder	
   .from(directQueue)	
   .to(new DirectExchange("amq.direct"))	
   .with("helloKey"));	
template.setExchange("amq.direct");	
	
template.convertAndSend("amq.direct","dropMe",	
  "I will be dropped!");	
template.convertAndSend("amq.direct","helloKey",	
  "Hi Direct!");	
Assert.assertEquals("Hi Direct!",	
  template.receiveAndConvert("direct"));	
Assert.assertNull(	
  template.receiveAndConvert("direct"));
Topic Exchange                X


•  Routing based on routing pattern
•  amq.topic is mandatory

•  E.g. for public / subscribe scenarios
Topic Exchange	
  

 order.DE
invoice.USD
         Topic
         Exchange
                    order.*
    P      X                         C


               invoice.*
                                     C
Headers Exchange                    X


•  Routing based on one or more headers and
   an expression
•  amqp.match is mandatory

•  Complex routing roles
Other Features
•  Message can be persistent
•  Request / response using correlations
   possible

•  Redelivery / acknowledgement possible

•  Clustering with e.g. Linux HA possible
•  ...or send message through multiple channels
   and drop duplicates
More about
RabbitMQ and Spring
Configuring Rabbit Resources with
             Spring
•  Spring enables decoupling of your application
   code from the underlying infrastructure

•  The container provides the resources

•  The application is simply coded against the
   API
Configuring a ConnectionFactory
<bean id="connectionFactory"
       class="org.sfw.amqp.rabbit.connection.SingleConnectionFactory">
  <property name="username" value="guest"/>
  <property name="password" value="guest"/>
   <constructor-arg value="localhost" />
</bean>

•  Can easily modify configuration options
Defining a RabbitTemplate Bean
 •  Provide a reference to the ConnectionFactory
 •  Optionally provide other references
     –  MessageConverter
     –  Routing key and exchange to be used if none is
        specified
<bean id="rabbitTemplate"
      class="org.springframework.amqp.rabbit.core.RabbitTemplate">
  <constructor-arg ref="connectionFactory" />
  <property name="routingKey" value=”invoice.USD" />
</bean>
The MessageListener
•  So far: Calling receive() on RabbitTemplate
•  Needed: Something that is called when a new
   message appears
•  The API defines this interface for
   asynchronous reception of messages
        public void onMessage(Message) {
          // handle the message
        }
Spring’s MessageListener
              Container
•  Spring provides lightweight containers to call
   MessageListeners
•  SimpleMessageListenerContainer
•  Advanced scheduling and endpoint
   management options available
•  i.e. thread pools, concurrent consumers,
   transaction handling
Defining a Message Listener
                Container
<bean class="org.sfw.amqp.rabbit.listener.SimpleMessageListenerContainer">
 <property name="connectionFactory" ref="connectionFactory" />
 <property name="queueNames" value="my.amqp.queue" />
 <property name="messageListener" ref="messageListener" />
</bean>


•  Every time a new message appears on
   my.amqp.queue the messageListener is
   called
Spring's message-driven objects
•  MessageListener means the receiver
   depends on Spring API
•  Why not just a POJO?
•  MessageListenerAdapter takes a POJO and
   makes it a MessageListener
•  i.e. calls consume on Bean consumer
<bean id="messageListenerAdapter"
        class="org.sfw.amqp.rabbit.listener.adapter.MessageListenerAdapter">
  <property name="delegate" ref="consumer" />
  <property name="defaultListenerMethod" value="consume" />
  <property name="messageConverter" ref="jsonMessageConverter" />
</bean>
Easier Using Namespaces
<rabbit:listener-container
 connection-factory="connectionFactory“
 message-converter="jsonMessageConverter">
    <rabbit:listener ref="consumer" method="consume"
                     queue-names="my.amqp.queue2" />
</rabbit:listener-container>


•  Results in the same Spring Beans
Consumer code
@Component	
public class Consumer {	
	
  public String consume(String message) {	
     return …;	
  }	
}

•  No dependency on AMQP!
•  But: What about the result of the method?
•  Send to the Reply-To address given in
   message properties with same correlationId
   as original method
Client Code
String response = (String) 	
  rabbitOperations.convertSendAndReceive(	
    "my.fanout", "", "test");

•  Message sent to destination with routing key
•  Reply-To set to exclusive, autodelete, non-
   durable queue
•  Response received through Reply-To
   converted and returned
•  Easy request-response!
•  Beware of potential latency
Create Environment
               Using Namespaces
<rabbit:fanout-exchange name="my.fanout2">
 <rabbit:bindings>
   <rabbit:binding queue="my.amqp.queue2" />
 </rabbit:bindings>
</rabbit:fanout-exchange>
<rabbit:queue name="my.amqp.queue2" />



•  ...if you don‘t like API calls
Conclusion: AMQP
•    Ubiquitous Messaging
•    AMQP: Protocol standard
•    Better scalability
•    Dynamic resources
Conclusion: Spring AMQP
•    Easy to use
•    Flexible (e.g. message encoding)
•    Allows scalable message handling
•    Full support for AMQP and RabbitMQ
More
•  http://springsource.org/spring-amqp
•  Also a .NET version available
•  …and support Spring Integration
•  http://blog.springsource.com/2011/04/01/
   routing-topologies-for-performance-and-
   scalability-with-rabbitm
•  Transaction support

•  …and there is very similar JMS support 

Weitere ähnliche Inhalte

Was ist angesagt?

Scaling applications with RabbitMQ at SunshinePHP
Scaling applications with RabbitMQ   at SunshinePHPScaling applications with RabbitMQ   at SunshinePHP
Scaling applications with RabbitMQ at SunshinePHPAlvaro Videla
 
Distributed messaging with AMQP
Distributed messaging with AMQPDistributed messaging with AMQP
Distributed messaging with AMQPWee Keat Chin
 
High powered messaging with RabbitMQ
High powered messaging with RabbitMQHigh powered messaging with RabbitMQ
High powered messaging with RabbitMQJames Carr
 
Messaging in the Cloud - AMQP, RabbitMQ and Spring
Messaging in the Cloud - AMQP, RabbitMQ and SpringMessaging in the Cloud - AMQP, RabbitMQ and Spring
Messaging in the Cloud - AMQP, RabbitMQ and SpringEberhard Wolff
 
Introduction To RabbitMQ
Introduction To RabbitMQIntroduction To RabbitMQ
Introduction To RabbitMQKnoldus Inc.
 
[@NaukriEngineering] Messaging Queues
[@NaukriEngineering] Messaging Queues[@NaukriEngineering] Messaging Queues
[@NaukriEngineering] Messaging QueuesNaukri.com
 
Practical Message Queuing Using RabbitMQ (PHPem, 3rd July 2014)
Practical Message Queuing Using RabbitMQ (PHPem, 3rd July 2014)Practical Message Queuing Using RabbitMQ (PHPem, 3rd July 2014)
Practical Message Queuing Using RabbitMQ (PHPem, 3rd July 2014)James Titcumb
 
Rabbit MQ introduction
Rabbit MQ introductionRabbit MQ introduction
Rabbit MQ introductionShirish Bari
 
RabbitMQ vs Apache Kafka Part II Webinar
RabbitMQ vs Apache Kafka Part II WebinarRabbitMQ vs Apache Kafka Part II Webinar
RabbitMQ vs Apache Kafka Part II WebinarErlang Solutions
 
Messaging Standards and Systems - AMQP & RabbitMQ
Messaging Standards and Systems - AMQP & RabbitMQMessaging Standards and Systems - AMQP & RabbitMQ
Messaging Standards and Systems - AMQP & RabbitMQPOSSCON
 
Full Stack Bus with Javascript, RabbitMQ and Postal.js
Full Stack Bus with Javascript, RabbitMQ and Postal.jsFull Stack Bus with Javascript, RabbitMQ and Postal.js
Full Stack Bus with Javascript, RabbitMQ and Postal.jsJavier Arias Losada
 
Easy enterprise application integration with RabbitMQ and AMQP
Easy enterprise application integration with RabbitMQ and AMQPEasy enterprise application integration with RabbitMQ and AMQP
Easy enterprise application integration with RabbitMQ and AMQPRabbit MQ
 
Alvaro Videla, Building a Distributed Data Ingestion System with RabbitMQ
Alvaro Videla, Building a Distributed Data Ingestion System with RabbitMQAlvaro Videla, Building a Distributed Data Ingestion System with RabbitMQ
Alvaro Videla, Building a Distributed Data Ingestion System with RabbitMQTanya Denisyuk
 

Was ist angesagt? (20)

Spring RabbitMQ
Spring RabbitMQSpring RabbitMQ
Spring RabbitMQ
 
Scaling applications with RabbitMQ at SunshinePHP
Scaling applications with RabbitMQ   at SunshinePHPScaling applications with RabbitMQ   at SunshinePHP
Scaling applications with RabbitMQ at SunshinePHP
 
Distributed messaging with AMQP
Distributed messaging with AMQPDistributed messaging with AMQP
Distributed messaging with AMQP
 
High powered messaging with RabbitMQ
High powered messaging with RabbitMQHigh powered messaging with RabbitMQ
High powered messaging with RabbitMQ
 
Messaging in the Cloud - AMQP, RabbitMQ and Spring
Messaging in the Cloud - AMQP, RabbitMQ and SpringMessaging in the Cloud - AMQP, RabbitMQ and Spring
Messaging in the Cloud - AMQP, RabbitMQ and Spring
 
Introduction To RabbitMQ
Introduction To RabbitMQIntroduction To RabbitMQ
Introduction To RabbitMQ
 
[@NaukriEngineering] Messaging Queues
[@NaukriEngineering] Messaging Queues[@NaukriEngineering] Messaging Queues
[@NaukriEngineering] Messaging Queues
 
Practical Message Queuing Using RabbitMQ (PHPem, 3rd July 2014)
Practical Message Queuing Using RabbitMQ (PHPem, 3rd July 2014)Practical Message Queuing Using RabbitMQ (PHPem, 3rd July 2014)
Practical Message Queuing Using RabbitMQ (PHPem, 3rd July 2014)
 
Rabbit MQ introduction
Rabbit MQ introductionRabbit MQ introduction
Rabbit MQ introduction
 
Message Broker System and RabbitMQ
Message Broker System and RabbitMQMessage Broker System and RabbitMQ
Message Broker System and RabbitMQ
 
RabbitMQ vs Apache Kafka Part II Webinar
RabbitMQ vs Apache Kafka Part II WebinarRabbitMQ vs Apache Kafka Part II Webinar
RabbitMQ vs Apache Kafka Part II Webinar
 
Messaging Standards and Systems - AMQP & RabbitMQ
Messaging Standards and Systems - AMQP & RabbitMQMessaging Standards and Systems - AMQP & RabbitMQ
Messaging Standards and Systems - AMQP & RabbitMQ
 
A Closer Look at RabbitMQ
A Closer Look at RabbitMQA Closer Look at RabbitMQ
A Closer Look at RabbitMQ
 
Full Stack Bus with Javascript, RabbitMQ and Postal.js
Full Stack Bus with Javascript, RabbitMQ and Postal.jsFull Stack Bus with Javascript, RabbitMQ and Postal.js
Full Stack Bus with Javascript, RabbitMQ and Postal.js
 
Easy enterprise application integration with RabbitMQ and AMQP
Easy enterprise application integration with RabbitMQ and AMQPEasy enterprise application integration with RabbitMQ and AMQP
Easy enterprise application integration with RabbitMQ and AMQP
 
Alvaro Videla, Building a Distributed Data Ingestion System with RabbitMQ
Alvaro Videla, Building a Distributed Data Ingestion System with RabbitMQAlvaro Videla, Building a Distributed Data Ingestion System with RabbitMQ
Alvaro Videla, Building a Distributed Data Ingestion System with RabbitMQ
 
AMQP for phpMelb
AMQP for phpMelbAMQP for phpMelb
AMQP for phpMelb
 
AMQP with RabbitMQ
AMQP with RabbitMQAMQP with RabbitMQ
AMQP with RabbitMQ
 
Amqp Basic
Amqp BasicAmqp Basic
Amqp Basic
 
RabbitMQ
RabbitMQRabbitMQ
RabbitMQ
 

Andere mochten auch

MongoUK 2011 - Rplacing RabbitMQ with MongoDB
MongoUK 2011 - Rplacing RabbitMQ with MongoDBMongoUK 2011 - Rplacing RabbitMQ with MongoDB
MongoUK 2011 - Rplacing RabbitMQ with MongoDBBoxed Ice
 
Introduction to RabbitMQ | Meetup at Pivotal Labs
Introduction to RabbitMQ | Meetup at Pivotal LabsIntroduction to RabbitMQ | Meetup at Pivotal Labs
Introduction to RabbitMQ | Meetup at Pivotal LabsAlvaro Videla
 
RabbitMQ Data Ingestion
RabbitMQ Data IngestionRabbitMQ Data Ingestion
RabbitMQ Data IngestionAlvaro Videla
 
Rabbitmq an amqp message broker
Rabbitmq an amqp message brokerRabbitmq an amqp message broker
Rabbitmq an amqp message brokerANASYS
 
10 Ways Your Boss Kills Employee Motivation
10 Ways Your Boss Kills Employee Motivation10 Ways Your Boss Kills Employee Motivation
10 Ways Your Boss Kills Employee MotivationOfficevibe
 
Top 5 Deep Learning and AI Stories - October 6, 2017
Top 5 Deep Learning and AI Stories - October 6, 2017Top 5 Deep Learning and AI Stories - October 6, 2017
Top 5 Deep Learning and AI Stories - October 6, 2017NVIDIA
 

Andere mochten auch (7)

MongoUK 2011 - Rplacing RabbitMQ with MongoDB
MongoUK 2011 - Rplacing RabbitMQ with MongoDBMongoUK 2011 - Rplacing RabbitMQ with MongoDB
MongoUK 2011 - Rplacing RabbitMQ with MongoDB
 
Introduction to RabbitMQ | Meetup at Pivotal Labs
Introduction to RabbitMQ | Meetup at Pivotal LabsIntroduction to RabbitMQ | Meetup at Pivotal Labs
Introduction to RabbitMQ | Meetup at Pivotal Labs
 
RabbitMQ Data Ingestion
RabbitMQ Data IngestionRabbitMQ Data Ingestion
RabbitMQ Data Ingestion
 
Rabbitmq an amqp message broker
Rabbitmq an amqp message brokerRabbitmq an amqp message broker
Rabbitmq an amqp message broker
 
dubizzle's Guide to RabbitMQ
dubizzle's Guide to RabbitMQdubizzle's Guide to RabbitMQ
dubizzle's Guide to RabbitMQ
 
10 Ways Your Boss Kills Employee Motivation
10 Ways Your Boss Kills Employee Motivation10 Ways Your Boss Kills Employee Motivation
10 Ways Your Boss Kills Employee Motivation
 
Top 5 Deep Learning and AI Stories - October 6, 2017
Top 5 Deep Learning and AI Stories - October 6, 2017Top 5 Deep Learning and AI Stories - October 6, 2017
Top 5 Deep Learning and AI Stories - October 6, 2017
 

Ähnlich wie The Future of Messaging: RabbitMQ and AMQP

Построение распределенной системы сбора данных с помощью RabbitMQ, Alvaro Vid...
Построение распределенной системы сбора данных с помощью RabbitMQ, Alvaro Vid...Построение распределенной системы сбора данных с помощью RabbitMQ, Alvaro Vid...
Построение распределенной системы сбора данных с помощью RabbitMQ, Alvaro Vid...Ontico
 
CBDW2014 - Down the RabbitMQ hole with ColdFusion
CBDW2014 - Down the RabbitMQ hole with ColdFusionCBDW2014 - Down the RabbitMQ hole with ColdFusion
CBDW2014 - Down the RabbitMQ hole with ColdFusionOrtus Solutions, Corp
 
Real time system_performance_mon
Real time system_performance_monReal time system_performance_mon
Real time system_performance_monTomas Doran
 
quickguide-einnovator-3-rabbitmq
quickguide-einnovator-3-rabbitmqquickguide-einnovator-3-rabbitmq
quickguide-einnovator-3-rabbitmqjorgesimao71
 
Exactly-once Semantics in Apache Kafka
Exactly-once Semantics in Apache KafkaExactly-once Semantics in Apache Kafka
Exactly-once Semantics in Apache Kafkaconfluent
 
Enterprise Messaging With ActiveMQ and Spring JMS
Enterprise Messaging With ActiveMQ and Spring JMSEnterprise Messaging With ActiveMQ and Spring JMS
Enterprise Messaging With ActiveMQ and Spring JMSBruce Snyder
 
TS 4839 - Enterprise Integration Patterns in Practice
TS 4839 - Enterprise Integration Patterns in PracticeTS 4839 - Enterprise Integration Patterns in Practice
TS 4839 - Enterprise Integration Patterns in Practiceaegloff
 
Ruby Microservices with RabbitMQ
Ruby Microservices with RabbitMQRuby Microservices with RabbitMQ
Ruby Microservices with RabbitMQZoran Majstorovic
 
Spark Kernel Talk - Apache Spark Meetup San Francisco (July 2015)
Spark Kernel Talk - Apache Spark Meetup San Francisco (July 2015)Spark Kernel Talk - Apache Spark Meetup San Francisco (July 2015)
Spark Kernel Talk - Apache Spark Meetup San Francisco (July 2015)Robert "Chip" Senkbeil
 
ITB2019 Multi-language / multi-OS communication using RabbitMQ - Wil de Bruin
ITB2019 Multi-language / multi-OS communication using RabbitMQ - Wil de BruinITB2019 Multi-language / multi-OS communication using RabbitMQ - Wil de Bruin
ITB2019 Multi-language / multi-OS communication using RabbitMQ - Wil de BruinOrtus Solutions, Corp
 

Ähnlich wie The Future of Messaging: RabbitMQ and AMQP (20)

Построение распределенной системы сбора данных с помощью RabbitMQ, Alvaro Vid...
Построение распределенной системы сбора данных с помощью RabbitMQ, Alvaro Vid...Построение распределенной системы сбора данных с помощью RabbitMQ, Alvaro Vid...
Построение распределенной системы сбора данных с помощью RabbitMQ, Alvaro Vid...
 
Follow the White Rabbit - Message Queues with PHP
Follow the White Rabbit - Message Queues with PHPFollow the White Rabbit - Message Queues with PHP
Follow the White Rabbit - Message Queues with PHP
 
CBDW2014 - Down the RabbitMQ hole with ColdFusion
CBDW2014 - Down the RabbitMQ hole with ColdFusionCBDW2014 - Down the RabbitMQ hole with ColdFusion
CBDW2014 - Down the RabbitMQ hole with ColdFusion
 
RabbitMQ and AMQP Model
RabbitMQ and AMQP ModelRabbitMQ and AMQP Model
RabbitMQ and AMQP Model
 
Real time system_performance_mon
Real time system_performance_monReal time system_performance_mon
Real time system_performance_mon
 
quickguide-einnovator-3-rabbitmq
quickguide-einnovator-3-rabbitmqquickguide-einnovator-3-rabbitmq
quickguide-einnovator-3-rabbitmq
 
Exactly-once Semantics in Apache Kafka
Exactly-once Semantics in Apache KafkaExactly-once Semantics in Apache Kafka
Exactly-once Semantics in Apache Kafka
 
Enterprise Messaging With ActiveMQ and Spring JMS
Enterprise Messaging With ActiveMQ and Spring JMSEnterprise Messaging With ActiveMQ and Spring JMS
Enterprise Messaging With ActiveMQ and Spring JMS
 
Enterprise messaging
Enterprise messagingEnterprise messaging
Enterprise messaging
 
TS 4839 - Enterprise Integration Patterns in Practice
TS 4839 - Enterprise Integration Patterns in PracticeTS 4839 - Enterprise Integration Patterns in Practice
TS 4839 - Enterprise Integration Patterns in Practice
 
Ruby Microservices with RabbitMQ
Ruby Microservices with RabbitMQRuby Microservices with RabbitMQ
Ruby Microservices with RabbitMQ
 
Pg amqp
Pg amqpPg amqp
Pg amqp
 
PostgreSQL: meet your queue
PostgreSQL: meet your queuePostgreSQL: meet your queue
PostgreSQL: meet your queue
 
Spark Kernel Talk - Apache Spark Meetup San Francisco (July 2015)
Spark Kernel Talk - Apache Spark Meetup San Francisco (July 2015)Spark Kernel Talk - Apache Spark Meetup San Francisco (July 2015)
Spark Kernel Talk - Apache Spark Meetup San Francisco (July 2015)
 
Rabbit MQ
Rabbit MQRabbit MQ
Rabbit MQ
 
MPI n OpenMP
MPI n OpenMPMPI n OpenMP
MPI n OpenMP
 
Spring integration
Spring integrationSpring integration
Spring integration
 
EIP In Practice
EIP In PracticeEIP In Practice
EIP In Practice
 
AMQP
AMQPAMQP
AMQP
 
ITB2019 Multi-language / multi-OS communication using RabbitMQ - Wil de Bruin
ITB2019 Multi-language / multi-OS communication using RabbitMQ - Wil de BruinITB2019 Multi-language / multi-OS communication using RabbitMQ - Wil de Bruin
ITB2019 Multi-language / multi-OS communication using RabbitMQ - Wil de Bruin
 

Mehr von Eberhard Wolff

Architectures and Alternatives
Architectures and AlternativesArchitectures and Alternatives
Architectures and AlternativesEberhard Wolff
 
The Frontiers of Continuous Delivery
The Frontiers of Continuous DeliveryThe Frontiers of Continuous Delivery
The Frontiers of Continuous DeliveryEberhard Wolff
 
Four Times Microservices - REST, Kubernetes, UI Integration, Async
Four Times Microservices - REST, Kubernetes, UI Integration, AsyncFour Times Microservices - REST, Kubernetes, UI Integration, Async
Four Times Microservices - REST, Kubernetes, UI Integration, AsyncEberhard Wolff
 
Microservices - not just with Java
Microservices - not just with JavaMicroservices - not just with Java
Microservices - not just with JavaEberhard Wolff
 
Deployment - Done Right!
Deployment - Done Right!Deployment - Done Right!
Deployment - Done Right!Eberhard Wolff
 
Data Architecture not Just for Microservices
Data Architecture not Just for MicroservicesData Architecture not Just for Microservices
Data Architecture not Just for MicroservicesEberhard Wolff
 
How to Split Your System into Microservices
How to Split Your System into MicroservicesHow to Split Your System into Microservices
How to Split Your System into MicroservicesEberhard Wolff
 
Microservices and Self-contained System to Scale Agile
Microservices and Self-contained System to Scale AgileMicroservices and Self-contained System to Scale Agile
Microservices and Self-contained System to Scale AgileEberhard Wolff
 
How Small Can Java Microservices Be?
How Small Can Java Microservices Be?How Small Can Java Microservices Be?
How Small Can Java Microservices Be?Eberhard Wolff
 
Data Architecturen Not Just for Microservices
Data Architecturen Not Just for MicroservicesData Architecturen Not Just for Microservices
Data Architecturen Not Just for MicroservicesEberhard Wolff
 
Microservices: Redundancy=Maintainability
Microservices: Redundancy=MaintainabilityMicroservices: Redundancy=Maintainability
Microservices: Redundancy=MaintainabilityEberhard Wolff
 
Self-contained Systems: A Different Approach to Microservices
Self-contained Systems: A Different Approach to MicroservicesSelf-contained Systems: A Different Approach to Microservices
Self-contained Systems: A Different Approach to MicroservicesEberhard Wolff
 
Microservices Technology Stack
Microservices Technology StackMicroservices Technology Stack
Microservices Technology StackEberhard Wolff
 
Software Architecture for Innovation
Software Architecture for InnovationSoftware Architecture for Innovation
Software Architecture for InnovationEberhard Wolff
 
Five (easy?) Steps Towards Continuous Delivery
Five (easy?) Steps Towards Continuous DeliveryFive (easy?) Steps Towards Continuous Delivery
Five (easy?) Steps Towards Continuous DeliveryEberhard Wolff
 
Nanoservices and Microservices with Java
Nanoservices and Microservices with JavaNanoservices and Microservices with Java
Nanoservices and Microservices with JavaEberhard Wolff
 
Microservices: Architecture to Support Agile
Microservices: Architecture to Support AgileMicroservices: Architecture to Support Agile
Microservices: Architecture to Support AgileEberhard Wolff
 
Microservices: Architecture to scale Agile
Microservices: Architecture to scale AgileMicroservices: Architecture to scale Agile
Microservices: Architecture to scale AgileEberhard Wolff
 
Microservices, DevOps, Continuous Delivery – More Than Three Buzzwords
Microservices, DevOps, Continuous Delivery – More Than Three BuzzwordsMicroservices, DevOps, Continuous Delivery – More Than Three Buzzwords
Microservices, DevOps, Continuous Delivery – More Than Three BuzzwordsEberhard Wolff
 

Mehr von Eberhard Wolff (20)

Architectures and Alternatives
Architectures and AlternativesArchitectures and Alternatives
Architectures and Alternatives
 
Beyond Microservices
Beyond MicroservicesBeyond Microservices
Beyond Microservices
 
The Frontiers of Continuous Delivery
The Frontiers of Continuous DeliveryThe Frontiers of Continuous Delivery
The Frontiers of Continuous Delivery
 
Four Times Microservices - REST, Kubernetes, UI Integration, Async
Four Times Microservices - REST, Kubernetes, UI Integration, AsyncFour Times Microservices - REST, Kubernetes, UI Integration, Async
Four Times Microservices - REST, Kubernetes, UI Integration, Async
 
Microservices - not just with Java
Microservices - not just with JavaMicroservices - not just with Java
Microservices - not just with Java
 
Deployment - Done Right!
Deployment - Done Right!Deployment - Done Right!
Deployment - Done Right!
 
Data Architecture not Just for Microservices
Data Architecture not Just for MicroservicesData Architecture not Just for Microservices
Data Architecture not Just for Microservices
 
How to Split Your System into Microservices
How to Split Your System into MicroservicesHow to Split Your System into Microservices
How to Split Your System into Microservices
 
Microservices and Self-contained System to Scale Agile
Microservices and Self-contained System to Scale AgileMicroservices and Self-contained System to Scale Agile
Microservices and Self-contained System to Scale Agile
 
How Small Can Java Microservices Be?
How Small Can Java Microservices Be?How Small Can Java Microservices Be?
How Small Can Java Microservices Be?
 
Data Architecturen Not Just for Microservices
Data Architecturen Not Just for MicroservicesData Architecturen Not Just for Microservices
Data Architecturen Not Just for Microservices
 
Microservices: Redundancy=Maintainability
Microservices: Redundancy=MaintainabilityMicroservices: Redundancy=Maintainability
Microservices: Redundancy=Maintainability
 
Self-contained Systems: A Different Approach to Microservices
Self-contained Systems: A Different Approach to MicroservicesSelf-contained Systems: A Different Approach to Microservices
Self-contained Systems: A Different Approach to Microservices
 
Microservices Technology Stack
Microservices Technology StackMicroservices Technology Stack
Microservices Technology Stack
 
Software Architecture for Innovation
Software Architecture for InnovationSoftware Architecture for Innovation
Software Architecture for Innovation
 
Five (easy?) Steps Towards Continuous Delivery
Five (easy?) Steps Towards Continuous DeliveryFive (easy?) Steps Towards Continuous Delivery
Five (easy?) Steps Towards Continuous Delivery
 
Nanoservices and Microservices with Java
Nanoservices and Microservices with JavaNanoservices and Microservices with Java
Nanoservices and Microservices with Java
 
Microservices: Architecture to Support Agile
Microservices: Architecture to Support AgileMicroservices: Architecture to Support Agile
Microservices: Architecture to Support Agile
 
Microservices: Architecture to scale Agile
Microservices: Architecture to scale AgileMicroservices: Architecture to scale Agile
Microservices: Architecture to scale Agile
 
Microservices, DevOps, Continuous Delivery – More Than Three Buzzwords
Microservices, DevOps, Continuous Delivery – More Than Three BuzzwordsMicroservices, DevOps, Continuous Delivery – More Than Three Buzzwords
Microservices, DevOps, Continuous Delivery – More Than Three Buzzwords
 

Kürzlich hochgeladen

Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 

Kürzlich hochgeladen (20)

Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 

The Future of Messaging: RabbitMQ and AMQP

  • 1. The Future of Messaging: RabbitMQ and AMQP Eberhard Wolff Architecture & Technology Manager adesso AG, Germany
  • 2. About me •  Eberhard Wolff •  Architecture & Technology Manager at adesso •  adesso is a leading IT consultancy in Germany •  Speaker •  Author (i.e. first German Spring book) •  Blog: http://ewolff.com •  Twitter: @ewolff •  eberhard.wolff@adesso.de
  • 3. Overview •  Why Messaging, AMQP and RabbitMQ •  Basic AMQP •  Advanced AMQP •  Advanced Spring-AMQP
  • 4. RPC •  Predominant approach –  RMI, SOAP Web Services, CORBA, HttpInvoker, Burlap, Hessian •  Calls remote methods with parameter •  …and waits for response •  Problems: –  Explicitly tells the server what to do i.e. tight coupling –  What about network failures? –  What about long latencies?
  • 5. Why Messaging? •  Decoupling –  Data, no action i.e. receiver Component can react arbitrarily –  Asynchronous i.e. decoupled by time •  Reliable –  Message can be stored-and- Component forwarded Messages –  Redelivery until message processed •  Solves typical problems of distributed systems
  • 6. Why Messaging? •  But: Requires different architecture •  Very different from calling remote methods •  Asynchronous •  AJAX has the same model •  See for example “Patterns of Enterprise Integration”
  • 7. Why AMQP? •  Open standard protocol •  Standard wire protocol •  i.e. just one client library – no matter which implementation you are using •  Less vendor lock in •  Efficient –  Binary wire protocol •  Support in all major languages •  Supported on most OS platforms
  • 8. What about JMS? •  JMS has been the default for Java messaging system for 10+ years •  But: •  Only standardized on the API level •  Less flexible than AMQP •  Mapping AMQP/JMS is being defined •  There is git://github.com/pieterh/openamq-jms.git
  • 9. Why Rabbit? •  Because it has a kewl name •  Numerous protocols supported •  Most popular choice on EC2 •  Foundation for demanding systems e.g. NASA’s cloud initiative Nebula •  Implemented in Erlang •  Clustering built in •  Currently in 2.4.1 •  Supports AMQP 0.8, 0.9, 0.9.1
  • 10. Broad Support in RabbitMQ
  • 11. Broad Support in the JVM Space •  Grails Plug In •  Java Client •  Scala / Lift support •  We will discuss Spring support in detail •  Spring AMQP project 1.0.0.RC1 •  http://www.springsource.org/spring-amqp
  • 12. Why Erlang? •  Originally designed for telephone switches by Ericsson •  Much easier to develop scalable and fault tolerant systems (by factors) •  See Motorola presentation: http://www.slideshare.net/Arbow/comparing- cpp-and-erlang-for-motorola-telecoms- software •  Good tool for reliable and scalable systems
  • 13. Erlang‘s Model Monitor Link to monitor, restart Light Light Light weight Messages weight Messages weight process process process with with with state state state
  • 14. Why Erlang? •  Let it crash –  If a process fails, it can be easily restarted –  Different approach to fault tolerance –  Otherwise lots of error handling •  Message Passing in the Core –  RabbitMQ is a messaging system… •  Light-weight process model –  Scalabiliy
  • 15. Very Basic AMQP •  Queues: Store messages •  Queues might be –  Durable: Survive server restarts –  Exclusive: For one connection –  autoDelete: Deleted if connection closes •  Queue usually created by consumer •  All resources are dynamic •  Producer sends a message to a Queue •  Let’s see some code…
  • 16. Spring’s RabbitTemplate •  Send & receive message •  AmqpTemplate: Generic AMQP interface •  RabbitOperations: Rabbit specific interface: (adds just a callback) •  RabbitTemplate: Implementation •  Spring might provide support for other AMQP implementations later •  Common interface
  • 17. Spring’s MessageConverter •  Messages are binary data •  RabbitTemplate uses MessageConverter to convert between objects and messages •  Can also send binary data if preferred •  Default: SimpleMessageConverter –  byte[] directly transferred –  String converted with configurable encoding –  Serializable are serialized –  Content type set accordingly •  JsonMessageConverter converts from / to JSON using Jackson •  MarshallingMessageConverter converts from / to XML using Spring's OXM mapping
  • 18. Spring‘s AdminTemplate •  Main purpose: Configure the AMQP infrastructure •  E.g. create queues •  AmpqAdmin: Generic AMQP interface •  RabbitAdmin: Rabbit specific
  • 19. Code ConnectionFactory conFactory = new SingleConnectionFactory("localhost"); RabbitTemplate template = new RabbitTemplate(conFactory); RabbitAdmin admin = new RabbitAdmin(conFactory); admin.declareQueue(new Queue("myQueue")); template.convertAndSend("myQueue", "Hi AMQP!"); String receive = (String) template.receiveAndConvert("myQueue"); Assert.assertEquals("Hi AMQP!", receive);
  • 20. Basics of AMQP •  Sending messages directly to queues is not enough •  What about e.g. pub / sub? •  Exchange: Route messages (stateless) •  Messages are byte-streams •  Example used the default exchange •  More dynamic, flexible and cleaner than JMS
  • 21. AMQP  in  a  nutshell   Exchange routes message Stateless Usually created by producer No queue: Message discarded X Binding binds an Exchange to a Queue Queues buffer messages Usually created by consumer
  • 22. AMQP  in  a  nutshell   Producer and Consumer might be written in Java, C#, Python, Ruby … C P X C AMQP RabbitMQ AMQP protocol protocol
  • 23. Exchange: Route Messages X •  The type of Exchange defined the routing algorithm used •  Binding provides selector for routing •  Exchange is addressed by name •  Some standard types •  Can provide additional ones
  • 24. Fanout Exchange X •  Broadcast to all bound queues •  Fast •  Simple •  amq.fanout is mandatory •  To broadcast information
  • 25. Fanout Exchange X C P X C Fanout C
  • 26. Queue fanoutQueue = new Queue("fanoutQueue"); admin.declareQueue(fanoutQueue); FanoutExchange fanoutExchange= new FanoutExchange("myFanout"); admin.declareExchange(fanoutExchange); admin.declareBinding( BindingBuilder.from(fanoutQueue). to(fanoutExchange)); template.setExchange("myFanout"); template.convertAndSend("Hi Fanout!"); String receive = (String) template.receiveAndConvert("fanoutQueue"); Assert.assertEquals("Hi Fanout!", receive);
  • 27. Direct Exchange X •  Routing based on one routing key •  amq.direct and the default Exchange (no name) always exist •  To send work orders to a specific worker
  • 28. Direct Exchange normal express Direct Exchange C express P X C normal C
  • 29. Queue directQueue = new Queue("direct"); admin.declareQueue(directQueue); admin.declareBinding(BindingBuilder .from(directQueue) .to(new DirectExchange("amq.direct")) .with("helloKey")); template.setExchange("amq.direct"); template.convertAndSend("amq.direct","dropMe", "I will be dropped!"); template.convertAndSend("amq.direct","helloKey", "Hi Direct!"); Assert.assertEquals("Hi Direct!", template.receiveAndConvert("direct")); Assert.assertNull( template.receiveAndConvert("direct"));
  • 30. Topic Exchange X •  Routing based on routing pattern •  amq.topic is mandatory •  E.g. for public / subscribe scenarios
  • 31. Topic Exchange   order.DE invoice.USD Topic Exchange order.* P X C invoice.* C
  • 32. Headers Exchange X •  Routing based on one or more headers and an expression •  amqp.match is mandatory •  Complex routing roles
  • 33. Other Features •  Message can be persistent •  Request / response using correlations possible •  Redelivery / acknowledgement possible •  Clustering with e.g. Linux HA possible •  ...or send message through multiple channels and drop duplicates
  • 35. Configuring Rabbit Resources with Spring •  Spring enables decoupling of your application code from the underlying infrastructure •  The container provides the resources •  The application is simply coded against the API
  • 36. Configuring a ConnectionFactory <bean id="connectionFactory" class="org.sfw.amqp.rabbit.connection.SingleConnectionFactory"> <property name="username" value="guest"/> <property name="password" value="guest"/> <constructor-arg value="localhost" /> </bean> •  Can easily modify configuration options
  • 37. Defining a RabbitTemplate Bean •  Provide a reference to the ConnectionFactory •  Optionally provide other references –  MessageConverter –  Routing key and exchange to be used if none is specified <bean id="rabbitTemplate" class="org.springframework.amqp.rabbit.core.RabbitTemplate"> <constructor-arg ref="connectionFactory" /> <property name="routingKey" value=”invoice.USD" /> </bean>
  • 38. The MessageListener •  So far: Calling receive() on RabbitTemplate •  Needed: Something that is called when a new message appears •  The API defines this interface for asynchronous reception of messages public void onMessage(Message) { // handle the message }
  • 39. Spring’s MessageListener Container •  Spring provides lightweight containers to call MessageListeners •  SimpleMessageListenerContainer •  Advanced scheduling and endpoint management options available •  i.e. thread pools, concurrent consumers, transaction handling
  • 40. Defining a Message Listener Container <bean class="org.sfw.amqp.rabbit.listener.SimpleMessageListenerContainer"> <property name="connectionFactory" ref="connectionFactory" /> <property name="queueNames" value="my.amqp.queue" /> <property name="messageListener" ref="messageListener" /> </bean> •  Every time a new message appears on my.amqp.queue the messageListener is called
  • 41. Spring's message-driven objects •  MessageListener means the receiver depends on Spring API •  Why not just a POJO? •  MessageListenerAdapter takes a POJO and makes it a MessageListener •  i.e. calls consume on Bean consumer <bean id="messageListenerAdapter" class="org.sfw.amqp.rabbit.listener.adapter.MessageListenerAdapter"> <property name="delegate" ref="consumer" /> <property name="defaultListenerMethod" value="consume" /> <property name="messageConverter" ref="jsonMessageConverter" /> </bean>
  • 42. Easier Using Namespaces <rabbit:listener-container connection-factory="connectionFactory“ message-converter="jsonMessageConverter"> <rabbit:listener ref="consumer" method="consume" queue-names="my.amqp.queue2" /> </rabbit:listener-container> •  Results in the same Spring Beans
  • 43. Consumer code @Component public class Consumer { public String consume(String message) { return …; } } •  No dependency on AMQP! •  But: What about the result of the method? •  Send to the Reply-To address given in message properties with same correlationId as original method
  • 44. Client Code String response = (String) rabbitOperations.convertSendAndReceive( "my.fanout", "", "test"); •  Message sent to destination with routing key •  Reply-To set to exclusive, autodelete, non- durable queue •  Response received through Reply-To converted and returned •  Easy request-response! •  Beware of potential latency
  • 45. Create Environment Using Namespaces <rabbit:fanout-exchange name="my.fanout2"> <rabbit:bindings> <rabbit:binding queue="my.amqp.queue2" /> </rabbit:bindings> </rabbit:fanout-exchange> <rabbit:queue name="my.amqp.queue2" /> •  ...if you don‘t like API calls
  • 46. Conclusion: AMQP •  Ubiquitous Messaging •  AMQP: Protocol standard •  Better scalability •  Dynamic resources
  • 47. Conclusion: Spring AMQP •  Easy to use •  Flexible (e.g. message encoding) •  Allows scalable message handling •  Full support for AMQP and RabbitMQ
  • 48. More •  http://springsource.org/spring-amqp •  Also a .NET version available •  …and support Spring Integration •  http://blog.springsource.com/2011/04/01/ routing-topologies-for-performance-and- scalability-with-rabbitm •  Transaction support •  …and there is very similar JMS support 