Your SlideShare is downloading. ×
RabbitMQ in PHP
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

RabbitMQ in PHP

10,017
views

Published on

An Introduction to implementing rabbitmq solution in php

An Introduction to implementing rabbitmq solution in php


0 Comments
5 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
10,017
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
47
Comments
0
Likes
5
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. RabbitMQ in PHPuse message broker rabbitmq in php Sergio Sicari <sergiosicari@gmail.com>
  • 2. What is a RabbitMQ?RabbitMQ is a messaging broker, a serviceplatform to send and receive messagesimplementing the Advanced MessageQueueing Protocol (AMQP).Its write in Erlang and open source.Its official supported on a number of operatingsystem and language (through API)
  • 3. Install the serviceOn Ubuntu from repository:1) Add the following line to your /etc/apt/sources.list: deb http://www.rabbitmq.com/debian/ testing main2) $ apt-get update3) $ sudo apt-get install rabbitmq-serverYou managing the service with rabbitmqctl $ rabbitmqctl stop/start $ rabbitmqctl status
  • 4. Managment (rabbitmqadmin*)The rabbitmq-management plugin provides an HTTP-basedAPI for management and monitoring of your RabbitMQserver, along with a browser-based UI and a command linetool.You can install with follow command:$ rabbitmq-plugins enable rabbitmq_managementNow you can manage RabbitMQ from web gui at:http://localhost:55672 *** rabbitmqadmin require Mochiweb web server** username: guest password: guest
  • 5. Use php 5.3*Use php-amqplib, a php implementation ofamqp protocol fromhttps://github.com/videlalvaro/php-amqplib$ git clone git://github.com/videlalvaro/php-amqplib.gituse composer to resolve depencies$ curl --silent https://getcomposer.org/installer | php$ php composer.phar install* this version of lib require php 5.3 because it use namespaces feature for use it on php 5.2 checkoutfrom http://code.google.com/p/php-amqplib/ and use require_once instead of namespaces
  • 6. Example:I have a process that execute two operation:1. Download and process some data (fast)2. Download image from web (slow)I dont want to wait for second operation,because its slow!I delegate the second operation to RabbitMQ
  • 7. Solve with RabbitMQStandard RabbitMQ init init download data download data Queue download images processing data processing data end end C Consumer: consumes the queued data "Processing data" step insert link in queue It will be disposed of by the consumer regardless
  • 8. Publisher Connection + Channel for AMQP Fast operation, run directly Put (publish) in Queue link for download image
  • 9. Consumer Connection + Channel for AMQP Process function (download images) this is a callback function used by basic_consume method for queue consume * When the process is completed consumer return an acknowledge to publisher *
  • 10. Referenceshttp://www.rabbitmq.com/ Official Sitehttps://github.com/videlalvaro/php-amqplib Php API (5.3)http://code.google.com/p/php-amqplib/ Php API (5.2) Sergio Sicari <sergiosicari@gmail.com>