Integrate RabbitMQ with Drupal

About Us

Love Huria

Drupal Devs @Srijan Technologies

@LoveHuria

Yogendra Prasad

@PrasadYogen

Agenda

  • About RabbitMQ
    • What is RabbitMQ?
    • Features
    • How it works? (Behind the scenes)
    • Exchange
    • AMQP Overview
  • RabbitMQ with PHP/Drupal.
  • Where can we use it?
  • Demo

What is RabbitMQ?

Integration Platform?

Messaging Server?

About RabbitMQ

  • Server that sends and receives messages
  • Developed and maintained by Rabbit Technologies Ltd.
  • Enterprise messaging system
  • Open Source MPL
  • Written in Erlang OTP
  • Commercial Support
  • Uses AMQP for messaging

Who is using?

...many more

Features

Multi protocol

Supports several messaging protocols directly or through plugins.

  • AMQP 0-9-1, 0-9 and 0-8, and extensions
  • AMQP 1.0
  • STOMP (Simple Text oriented messaging protocol)
  • MQTT (Message Queue Telemetry Transport)
  • HTTP

Scalability

Cross Platform (RabbitMQ is for everyone)

  • PHP
  • Node.js
  • Java
  • Ruby
  • Objective-C & Swift
  • .NET
  • Go
  • Perl
  • Haskell

Management UI

  • Plugin that can be enabled for RabbitMQ.
  • Can monitor and handle your RabbitMQ server from a web browser.
  • Static HTML page that makes background queries to the HTTP API for RabbitMQ.
  • High unacked messages ~ Low consumers
  • Management interface can be helpful for debugging you application.

Management UI

High Queues availability

Mirrored Queues:

 

  • Works by allowing queue to be mirrored on other nodes within a RabbitMQ cluster. So if one node of the cluster fails, the queue can automatically be switched to one of the mirrors and continue to operate even without the unavailability of the service.
  • Improves the availability of the service.

              Clustering:

  • RabbitMQ is a logical grouping of Erlang nodes, and in this case node is nothing its basically a computer or an instance. 
  • Collection of nodes is called clustering.

Features

  • Multi protocol
  • Scalability
  • Easy to install
  • Cross Platform
  • Easy to use Management UI
  • High Queues availability

Tell me more..

P2

C

P3

P1

M1

M2

M3

M4

M5

M6

M7

Message broker

P

Message broker

C

No Consumer ?

M1

M2

M3

M4

M5

M6

M7

Tell me more..

P

Message broker

C

When Consumer

comes

Messages consumed

Tell me more..

P

Message broker

C

M1

M2

M3

M4

M5

M6

M7

P

Publisher & Consumer both are not available

Tell me more..

Exchange

  • Message routing agent
  • Can be durable, temporary or Auto deleted
    • Durable - Stays up even if server restarts
    • Temporary - Gets deleted when server is shutdown
    • AD - Exchange is deleted when all queues have finished using it
  • Several type of exchange types, which works on a particular algorithm
  • Binding - This is a link between queue and exchange
  • Routing key -  Message attribute

Exchange Types

P

Exchange

binding

  • Direct Exchange
  • Fanout Exchange
  • Topic Exchange

C

Direct Exchange

  • The binding key must match the routing key exactly - no wildcard support.

(Image source: https://lostechies.com)

Fanout Exchange

  • The routing and binding keys are ignored - all published messages go to all bound queues.

(Image source: https://lostechies.com)

Topic Exchange

  • Same as Direct, but wildcards are allowed in the binding key. '#' matches zero or more dot-delimited words and '*' matches exactly one such word.

(Image source: https://lostechies.com)

AMQP (Overview)

  • Advanced Message Queueing Protocol
  • Open source
  • Binary Wire Protocol Standard
  • Support in various languages 
  • Interoperable
  • Reliable and Secure
  • Implementations: Apache Qpid, RabbitMQ, ActiveMQ (>5.8)

RabbitMQ with Drupal/PHP

  • Installation and documentation is well explained on the RabbitMQ website (http://rabbitmq.com)
  • Module available for Drupal 7 & Drupal 8 (https://www.drupal.org/project/rabbitmq)
  • Actively maintained PHP AMQP library (https://github.com/php-amqplib/php-amqplib)
  • PHP has an extension of AMQP protocol (https://pecl.php.net/package/amqp)

With RabbitMQ we can

 

  • Monitor data feeds
  • Need things to be done in order
  • Logging
  • Huge amount of data to be delivered
  • Chat
  • Emails broadcast
  • And where ever you want to run things asynchronously

References

  • RabbitMQ (http://www.rabbitmq.com/getstarted.html)
  • Spring.io (https://spring.io/blog/2010/06/14/understanding-amqp-the-protocol-used-by-rabbitmq/)
  • Lostechies (https://lostechies.com/derekgreer/2012/03/28/rabbitmq-for-windows-exchange-types/)

</Thank You>

Questions?

RabbitMQ with Drupal 7

By Love Huria

RabbitMQ with Drupal 7

Let's make web applications talk to each other.

  • 2,488