Message Oriented Middleware

Decoupling your service



Github Thiago Dantas / Twitter @thiagochapa

Agenda


            $ git tag -ln
                        v0.1     Talking about entities
            v1.0     Topic with Durable Options
            v1.1     Topic Wildcard
            v1.2     Topic Automatic ACK
            v1.3     Topic Explicit ACK
            v1.4     Reliable Mode


let's create a BIG COMPLEX PROJECT


 services instead of monolithic architecture software


We are getting bigGer



Biger biger



BIGER BIGER BIGER



BIGER BIGER BIGER BIGER



Did you see any problem ?


  • creates dependencies between the applications.
  • when point-to-point connectivity exists, the coupling has a quadratic  growth with the number of applications.
  • You must implement all communcation with other services.




RESCUE

call to mom


Rabbit MQ



Entities


  • EXCHANGES
  • BINDINGS
  • QUEUES

EXCHANGEs



Exchanges are AMQP entities where messages are sent. 
Exchanges take a message and route it into zero or more queues. 
The routing algorithm used depends on the exchange type and rules called bindings.

EXCHANGES


image:  http://www.rabbitmq.com/

EXCHANGE TYPES



Direct
Fanout
Topic 
Headers

EXCHANGE

DIRECT

fanout


TOPIC



EXCHANGEs

Properties

 

            Name              Exchange Name - ampq.* are reserved                         Durability                 Will survive broker restart                        Auto-Delete              Deleted when all queues have finished


QUEUES

Store messages that are consumed by applications.

        Name     Queue Name   Durable      Will survive a broker restart
Exclusive Used by only one connection and deleted when connection close
Auto-Delete  Deleted when last consumer unsubscribes

BINDINGS

The Clue



              Rules that exchanges use to route messages to queues. 

HANDS ON




git checkout -b v0.1 tags/v0.1 First Date with MOM

HANDS ON

Topic 

Surviving crash


                                git checkout -b v1.0 tags/v1.0                        spreading the word

HANDS ON

WiLdcard


                  git checkout -b 'v1.1' tags/v1.1                         weather forecast

HANDS ON

                                      Acknowledgements


                  git checkout -b v1.1 tags/v1.1                      automatic ack model
git checkout -b v1.2 tags/v1.2 explicit ack model

ACK

reliable mode

Broker <----> Consumer



ACK

RELIABLE MODE

Producer <---> Broker

HANDS ON

RELIABLE MODE

                   git checkout -b v1.4 tags/v1.4                      confirm_select + ack                              


THANK YOU

Backshop - decoupling-services

By tdantas

Backshop - decoupling-services

Use Message Bus to decouple our Services

  • 300