SlideShare a Scribd company logo
1 of 17
RabbitMQ
AMQP in PHP
Blaž Strmole, Bled, 12. 2. 2015
RabbitMQ
● Message broker
● AMQP in še več
● Napisan v Erlang-u
● Open source
AMQP
● Advanced Message Queuing Protocol
● AMQP is a networking protocol that enables
conforming client applications to
communicate with conforming messaging
middleware brokers.
AMQP - zgodovina
● Zasnovan 2003
● Najprej ga uporabljajo v finančnih aplikacijah
● Nov 2008 izdajo verzijo 0.9.1
● Nov 2011 izdajo verzijo 1.0
● Okt 2012 potrjen kot OASIS standard
● RabbitMQ uporablja 0.9.1
AMQP - model
● Publisher pošlje sporočilo v Exchange
(mailbox).
● Glede na routing se sporočilo distribuira v
Queues.
● Broker ga posreduje Consumer-ju ali pa ga
consumer sam potegne iz queue.
● RabbitMq == Exchange + Queues + Broker
AMQP - Exchange
● Sporočila so poslana sem.
● Vedno obstaja privzet Exchange
● Tu se izvaja routing.
AMQP - direct routing
● Sporočila gredo v določeno vrsto.
● Uporabno za workerje (gearman).
Publisher Queue Consumer
AMQP - fanout routing
● Vsako sporočilo gre v več vrst.
● Naredi se kopija sporočila za vsako vrsto.
Publisher Queue2 Consumer2
Consumer1
Consumer3
AMQP - topic routing
● Sporočilo gre v eno ali več vrst.
● Kam gre se določi glede na routing key od
sporočila.
● Pravila se določijo v Exchange.
AMQP - header routing
● Sporočilo gre v eno vrsto.
● Kam gre se določi s header atributi.
● Podpira any ali all.
● Direct routing on steroids.
AMQP - queues
● Jih je potrebno predhodno določiti (declare).
● Imajo več lastnosti:
– Ime
– Persistenco (durable)
– Exclusive
– Auto-delete
– Argumente
AMQP - consumers
● Push
● Pull
● Lahko več na eno vrsto
● Exclusive consumer
● Potrditev prejema sporočila
(acknowledgement)
● Zavrnitev sporočila
AMQP - connections
● TCP
● Uporabljajo avtentikacijo
● Lahko tudi TLS (SSL)
● Jih je potrrebno zaključevati (close)
RabbitMQ - PHP
● Php-amqplib
– Spisana v PHP (5.3)
– Avtor: Alvaro Videla
– Podpira vse kar RabbitMQ
● Pecl AMQP lib
– Bazira na RabbitMQ C AMQP client lib
RabbitMQ – Primer publisher
use PhpAmqpLibConnectionAMQPConnection;
use PhpAmqpLibMessageAMQPMessage;
$connection = new AMQPConnection('localhost', 5672, 'guest', 'guest');
$channel = $connection->channel();
$channel->queue_declare('hello', false, false, false, false);
$msg = new AMQPMessage('Hello World!');
$channel->basic_publish($msg, '', 'hello');
echo " [x] Sent 'Hello World!'n";
$channel->close();
$connection->close();
RabbitMQ – Primer consumer
use PhpAmqpLibConnectionAMQPConnection;
$connection = new AMQPConnection('localhost', 5672, 'guest', 'guest');
$channel = $connection->channel();
$channel->queue_declare('hello', false, false, false, false);
$callback = function($msg) {
echo " [x] Received ", $msg->body, "n";
};
$channel->basic_consume('hello', '', false, true, false, false, $callback);
echo ' [*] Waiting for messages. To exit press CTRL+C', "n";
while(count($channel->callbacks)) {
$channel->wait();
}
$channel->close();
$connection->close();
Vprašanja?
RabbitMQ, AMQP in PHP

More Related Content

What's hot

Messaging Standards and Systems - AMQP & RabbitMQ
Messaging Standards and Systems - AMQP & RabbitMQMessaging Standards and Systems - AMQP & RabbitMQ
Messaging Standards and Systems - AMQP & RabbitMQAll Things Open
 
Distributed messaging with AMQP
Distributed messaging with AMQPDistributed messaging with AMQP
Distributed messaging with AMQPWee Keat Chin
 
What we've learned from running thousands of production RabbitMQ clusters - L...
What we've learned from running thousands of production RabbitMQ clusters - L...What we've learned from running thousands of production RabbitMQ clusters - L...
What we've learned from running thousands of production RabbitMQ clusters - L...RabbitMQ Summit
 
RabbitMQ And Nanite
RabbitMQ And NaniteRabbitMQ And Nanite
RabbitMQ And Nanitemattmatt
 
Introduction To RabbitMQ
Introduction To RabbitMQIntroduction To RabbitMQ
Introduction To RabbitMQKnoldus Inc.
 
Messaging with amqp and rabbitmq
Messaging with amqp and rabbitmqMessaging with amqp and rabbitmq
Messaging with amqp and rabbitmqSelasie Hanson
 
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
 
Messaging Standards and Systems - AMQP & RabbitMQ
Messaging Standards and Systems - AMQP & RabbitMQMessaging Standards and Systems - AMQP & RabbitMQ
Messaging Standards and Systems - AMQP & RabbitMQPOSSCON
 
[@NaukriEngineering] Messaging Queues
[@NaukriEngineering] Messaging Queues[@NaukriEngineering] Messaging Queues
[@NaukriEngineering] Messaging QueuesNaukri.com
 
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
 
Architecture | The Future of Messaging: RabbitMQ and AMQP | Eberhard Wolff
Architecture | The Future of Messaging: RabbitMQ and AMQP | Eberhard WolffArchitecture | The Future of Messaging: RabbitMQ and AMQP | Eberhard Wolff
Architecture | The Future of Messaging: RabbitMQ and AMQP | Eberhard WolffJAX London
 
Rabbitmq, amqp Intro - Messaging Patterns
Rabbitmq, amqp Intro - Messaging PatternsRabbitmq, amqp Intro - Messaging Patterns
Rabbitmq, amqp Intro - Messaging PatternsJavier Arias Losada
 
Build reliable, traceable, distributed systems with ZeroMQ
Build reliable, traceable, distributed systems with ZeroMQBuild reliable, traceable, distributed systems with ZeroMQ
Build reliable, traceable, distributed systems with ZeroMQRobin Xiao
 
Leveraging zeromq for node.js
Leveraging zeromq for node.jsLeveraging zeromq for node.js
Leveraging zeromq for node.jsRuben Tan
 

What's hot (20)

Messaging Standards and Systems - AMQP & RabbitMQ
Messaging Standards and Systems - AMQP & RabbitMQMessaging Standards and Systems - AMQP & RabbitMQ
Messaging Standards and Systems - AMQP & RabbitMQ
 
Distributed messaging with AMQP
Distributed messaging with AMQPDistributed messaging with AMQP
Distributed messaging with AMQP
 
What we've learned from running thousands of production RabbitMQ clusters - L...
What we've learned from running thousands of production RabbitMQ clusters - L...What we've learned from running thousands of production RabbitMQ clusters - L...
What we've learned from running thousands of production RabbitMQ clusters - L...
 
RabbitMQ And Nanite
RabbitMQ And NaniteRabbitMQ And Nanite
RabbitMQ And Nanite
 
Introduction To RabbitMQ
Introduction To RabbitMQIntroduction To RabbitMQ
Introduction To RabbitMQ
 
Messaging with amqp and rabbitmq
Messaging with amqp and rabbitmqMessaging with amqp and rabbitmq
Messaging with amqp and rabbitmq
 
What is RabbitMQ ?
What is RabbitMQ ?What is RabbitMQ ?
What is RabbitMQ ?
 
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
 
NullMQ @ PDX
NullMQ @ PDXNullMQ @ PDX
NullMQ @ PDX
 
Amqp Basic
Amqp BasicAmqp Basic
Amqp Basic
 
A Closer Look at RabbitMQ
A Closer Look at RabbitMQA Closer Look at RabbitMQ
A Closer Look at RabbitMQ
 
Messaging Standards and Systems - AMQP & RabbitMQ
Messaging Standards and Systems - AMQP & RabbitMQMessaging Standards and Systems - AMQP & RabbitMQ
Messaging Standards and Systems - AMQP & RabbitMQ
 
[@NaukriEngineering] Messaging Queues
[@NaukriEngineering] Messaging Queues[@NaukriEngineering] Messaging Queues
[@NaukriEngineering] Messaging Queues
 
ZeroMQ with NodeJS
ZeroMQ with NodeJSZeroMQ with NodeJS
ZeroMQ with NodeJS
 
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
 
Architecture | The Future of Messaging: RabbitMQ and AMQP | Eberhard Wolff
Architecture | The Future of Messaging: RabbitMQ and AMQP | Eberhard WolffArchitecture | The Future of Messaging: RabbitMQ and AMQP | Eberhard Wolff
Architecture | The Future of Messaging: RabbitMQ and AMQP | Eberhard Wolff
 
Rabbitmq, amqp Intro - Messaging Patterns
Rabbitmq, amqp Intro - Messaging PatternsRabbitmq, amqp Intro - Messaging Patterns
Rabbitmq, amqp Intro - Messaging Patterns
 
Think beyond http
Think beyond httpThink beyond http
Think beyond http
 
Build reliable, traceable, distributed systems with ZeroMQ
Build reliable, traceable, distributed systems with ZeroMQBuild reliable, traceable, distributed systems with ZeroMQ
Build reliable, traceable, distributed systems with ZeroMQ
 
Leveraging zeromq for node.js
Leveraging zeromq for node.jsLeveraging zeromq for node.js
Leveraging zeromq for node.js
 

Similar to Rabbit mq, amqp and php

quickguide-einnovator-3-rabbitmq
quickguide-einnovator-3-rabbitmqquickguide-einnovator-3-rabbitmq
quickguide-einnovator-3-rabbitmqjorgesimao71
 
Integrating PostgreSql with RabbitMQ
Integrating PostgreSql with RabbitMQIntegrating PostgreSql with RabbitMQ
Integrating PostgreSql with RabbitMQGavin Roy
 
XMPP & AMQP in Ruby
XMPP & AMQP in RubyXMPP & AMQP in Ruby
XMPP & AMQP in RubyMatt Todd
 
Message Queuing - Gearman, Mosquitto, Kafka and RabbitMQ
Message Queuing - Gearman, Mosquitto, Kafka and RabbitMQMessage Queuing - Gearman, Mosquitto, Kafka and RabbitMQ
Message Queuing - Gearman, Mosquitto, Kafka and RabbitMQMarian Marinov
 
Commication Framework in OpenStack
Commication Framework in OpenStackCommication Framework in OpenStack
Commication Framework in OpenStackSean Chang
 
Построение распределенной системы сбора данных с помощью RabbitMQ, Alvaro Vid...
Построение распределенной системы сбора данных с помощью RabbitMQ, Alvaro Vid...Построение распределенной системы сбора данных с помощью RabbitMQ, Alvaro Vid...
Построение распределенной системы сбора данных с помощью RabbitMQ, Alvaro Vid...Ontico
 
IBM MQ Clustering (2017 version)
IBM MQ Clustering (2017 version)IBM MQ Clustering (2017 version)
IBM MQ Clustering (2017 version)MarkTaylorIBM
 
RabbitMQ interview Questions and Answers
RabbitMQ interview Questions and AnswersRabbitMQ interview Questions and Answers
RabbitMQ interview Questions and Answersjeetendra mandal
 
Messaging for Modern Applications
Messaging for Modern ApplicationsMessaging for Modern Applications
Messaging for Modern ApplicationsTom McCuch
 
Russell spring one2gx_messaging_india
Russell spring one2gx_messaging_indiaRussell spring one2gx_messaging_india
Russell spring one2gx_messaging_indiaGaryPRussell
 
Introducing Kafka-on-Pulsar: bring native Kafka protocol support to Apache Pu...
Introducing Kafka-on-Pulsar: bring native Kafka protocol support to Apache Pu...Introducing Kafka-on-Pulsar: bring native Kafka protocol support to Apache Pu...
Introducing Kafka-on-Pulsar: bring native Kafka protocol support to Apache Pu...StreamNative
 
JDD 2017: Brace yourself! Storm is coming! (Łukasz Gebel, Michał Koziorowski)
JDD 2017: Brace yourself! Storm is coming! (Łukasz Gebel, Michał Koziorowski)JDD 2017: Brace yourself! Storm is coming! (Łukasz Gebel, Michał Koziorowski)
JDD 2017: Brace yourself! Storm is coming! (Łukasz Gebel, Michał Koziorowski)PROIDEA
 

Similar to Rabbit mq, amqp and php (20)

quickguide-einnovator-3-rabbitmq
quickguide-einnovator-3-rabbitmqquickguide-einnovator-3-rabbitmq
quickguide-einnovator-3-rabbitmq
 
Integrating PostgreSql with RabbitMQ
Integrating PostgreSql with RabbitMQIntegrating PostgreSql with RabbitMQ
Integrating PostgreSql with RabbitMQ
 
XMPP & AMQP in Ruby
XMPP & AMQP in RubyXMPP & AMQP in Ruby
XMPP & AMQP in Ruby
 
Message Queuing - Gearman, Mosquitto, Kafka and RabbitMQ
Message Queuing - Gearman, Mosquitto, Kafka and RabbitMQMessage Queuing - Gearman, Mosquitto, Kafka and RabbitMQ
Message Queuing - Gearman, Mosquitto, Kafka and RabbitMQ
 
Spring RabbitMQ
Spring RabbitMQSpring RabbitMQ
Spring RabbitMQ
 
RabbitMQ and AMQP Model
RabbitMQ and AMQP ModelRabbitMQ and AMQP Model
RabbitMQ and AMQP Model
 
AMQP with RabbitMQ
AMQP with RabbitMQAMQP with RabbitMQ
AMQP with RabbitMQ
 
Rabbit MQ
Rabbit MQRabbit MQ
Rabbit MQ
 
Commication Framework in OpenStack
Commication Framework in OpenStackCommication Framework in OpenStack
Commication Framework in OpenStack
 
Pg amqp
Pg amqpPg amqp
Pg amqp
 
PostgreSQL: meet your queue
PostgreSQL: meet your queuePostgreSQL: meet your queue
PostgreSQL: meet your queue
 
Построение распределенной системы сбора данных с помощью RabbitMQ, Alvaro Vid...
Построение распределенной системы сбора данных с помощью RabbitMQ, Alvaro Vid...Построение распределенной системы сбора данных с помощью RabbitMQ, Alvaro Vid...
Построение распределенной системы сбора данных с помощью RabbitMQ, Alvaro Vid...
 
IBM MQ Clustering (2017 version)
IBM MQ Clustering (2017 version)IBM MQ Clustering (2017 version)
IBM MQ Clustering (2017 version)
 
zeromq
zeromqzeromq
zeromq
 
RabbitMQ interview Questions and Answers
RabbitMQ interview Questions and AnswersRabbitMQ interview Questions and Answers
RabbitMQ interview Questions and Answers
 
Messaging for Modern Applications
Messaging for Modern ApplicationsMessaging for Modern Applications
Messaging for Modern Applications
 
Russell spring one2gx_messaging_india
Russell spring one2gx_messaging_indiaRussell spring one2gx_messaging_india
Russell spring one2gx_messaging_india
 
Introducing Kafka-on-Pulsar: bring native Kafka protocol support to Apache Pu...
Introducing Kafka-on-Pulsar: bring native Kafka protocol support to Apache Pu...Introducing Kafka-on-Pulsar: bring native Kafka protocol support to Apache Pu...
Introducing Kafka-on-Pulsar: bring native Kafka protocol support to Apache Pu...
 
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
 
JDD 2017: Brace yourself! Storm is coming! (Łukasz Gebel, Michał Koziorowski)
JDD 2017: Brace yourself! Storm is coming! (Łukasz Gebel, Michał Koziorowski)JDD 2017: Brace yourself! Storm is coming! (Łukasz Gebel, Michał Koziorowski)
JDD 2017: Brace yourself! Storm is coming! (Łukasz Gebel, Michał Koziorowski)
 

Recently uploaded

SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 

Recently uploaded (20)

SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 

Rabbit mq, amqp and php

  • 1. RabbitMQ AMQP in PHP Blaž Strmole, Bled, 12. 2. 2015
  • 2. RabbitMQ ● Message broker ● AMQP in še več ● Napisan v Erlang-u ● Open source
  • 3. AMQP ● Advanced Message Queuing Protocol ● AMQP is a networking protocol that enables conforming client applications to communicate with conforming messaging middleware brokers.
  • 4. AMQP - zgodovina ● Zasnovan 2003 ● Najprej ga uporabljajo v finančnih aplikacijah ● Nov 2008 izdajo verzijo 0.9.1 ● Nov 2011 izdajo verzijo 1.0 ● Okt 2012 potrjen kot OASIS standard ● RabbitMQ uporablja 0.9.1
  • 5. AMQP - model ● Publisher pošlje sporočilo v Exchange (mailbox). ● Glede na routing se sporočilo distribuira v Queues. ● Broker ga posreduje Consumer-ju ali pa ga consumer sam potegne iz queue. ● RabbitMq == Exchange + Queues + Broker
  • 6. AMQP - Exchange ● Sporočila so poslana sem. ● Vedno obstaja privzet Exchange ● Tu se izvaja routing.
  • 7. AMQP - direct routing ● Sporočila gredo v določeno vrsto. ● Uporabno za workerje (gearman). Publisher Queue Consumer
  • 8. AMQP - fanout routing ● Vsako sporočilo gre v več vrst. ● Naredi se kopija sporočila za vsako vrsto. Publisher Queue2 Consumer2 Consumer1 Consumer3
  • 9. AMQP - topic routing ● Sporočilo gre v eno ali več vrst. ● Kam gre se določi glede na routing key od sporočila. ● Pravila se določijo v Exchange.
  • 10. AMQP - header routing ● Sporočilo gre v eno vrsto. ● Kam gre se določi s header atributi. ● Podpira any ali all. ● Direct routing on steroids.
  • 11. AMQP - queues ● Jih je potrebno predhodno določiti (declare). ● Imajo več lastnosti: – Ime – Persistenco (durable) – Exclusive – Auto-delete – Argumente
  • 12. AMQP - consumers ● Push ● Pull ● Lahko več na eno vrsto ● Exclusive consumer ● Potrditev prejema sporočila (acknowledgement) ● Zavrnitev sporočila
  • 13. AMQP - connections ● TCP ● Uporabljajo avtentikacijo ● Lahko tudi TLS (SSL) ● Jih je potrrebno zaključevati (close)
  • 14. RabbitMQ - PHP ● Php-amqplib – Spisana v PHP (5.3) – Avtor: Alvaro Videla – Podpira vse kar RabbitMQ ● Pecl AMQP lib – Bazira na RabbitMQ C AMQP client lib
  • 15. RabbitMQ – Primer publisher use PhpAmqpLibConnectionAMQPConnection; use PhpAmqpLibMessageAMQPMessage; $connection = new AMQPConnection('localhost', 5672, 'guest', 'guest'); $channel = $connection->channel(); $channel->queue_declare('hello', false, false, false, false); $msg = new AMQPMessage('Hello World!'); $channel->basic_publish($msg, '', 'hello'); echo " [x] Sent 'Hello World!'n"; $channel->close(); $connection->close();
  • 16. RabbitMQ – Primer consumer use PhpAmqpLibConnectionAMQPConnection; $connection = new AMQPConnection('localhost', 5672, 'guest', 'guest'); $channel = $connection->channel(); $channel->queue_declare('hello', false, false, false, false); $callback = function($msg) { echo " [x] Received ", $msg->body, "n"; }; $channel->basic_consume('hello', '', false, true, false, false, $callback); echo ' [*] Waiting for messages. To exit press CTRL+C', "n"; while(count($channel->callbacks)) { $channel->wait(); } $channel->close(); $connection->close();

Editor's Notes

  1. message-oriented middleware exchange server Publisher (vaš program) → rabbitMQ (server) → consumer (worker) cluster Amqp = Advanced Message Queuing Protocol Več kasneje... Erlang – razvil ericsson, 1986 od 1998 open source
  2. Organization for the Advancement of Structured Information Standards 0.9 to 1.0 totalna razlika, ni več celotna infrastruktura ampak samo še protokola za izmenjavo sporočil Nista kompatibilna v nobeno smer
  3. Vsak node je lahko na svoji mašini Celoten protokol je programabilen
  4. Exchange ima IME, persistance (ali preživi restart), auto delete (se pobriše, ko so vsi queue izprazneni), itd. Privzet Default exchange - noname - navidezno se poveže na vse queue, po imenu Štirje tipi routinga: - direct - fan out - topic - headers
  5. Queue ima lahko več consumerjev. Sporočilo prejme samo eden (tisti, ki je na razpolago)
  6. Broadcast Group chat
  7. Primeri uporabe - geolocation distibucija - os specifični workerji - workerji :)
  8. Tako kot http message ima tudi amqp message header Lahko več atributov In / ali X-match atribut to določa Ignorira routing key, prioriteta pred vsem drugim
  9. Ime 255 bytov utf8 Lahko se generira avtomatsko Amq na začetku je prepovedan, rezervirano Durable Durable so zapisane na disk Preživijo restart Exclusive Uporabne samo z eno povezavo Se uničijo če se uniči povezava Auto delete Se pobrišejo, ko se odjavi zadnji consumer Argumenti, za dodatne funkcionalnosti ala TTL - določeni Content type, encoding, routing key, priority,...
  10. exclusive consumer Noben drug ne more jemati iz vrste dokler to dela on Potrditev - ko se pošlje consumerju, auto ack - consumer mora potrditi prejem/obdelavo - sporočilo ostane dokler ni potrjeno Zavrnitev - reject → discard or requeue
  11. Avtentikacija user + pass
  12. Alvaro Videla – tudi razvijalec pri rabbitMQ Takoj kot je kaj novega je tudi tu (extensions, plugini) Relativno počasna za povezavo uporablja stream_socket_client Pecl hitra, izkušnje Obe sta amqp knjižnjice in se lahko uporabljata z katerimkoli sistemov ki pozna amqp 9.1 StormMQ, Apache Qpid,
  13. queue_declare Ime, passive, durable, exclusive, auto-delete Passive = false, jo naredi če je še ni Passive = true, se samo proba povezati nanjo, če je ni dobimo error (exception)
  14. queue_declare Ime, passive, durable, exclusive, auto-delete basic_consume Queue ime, hello consumer tag, prazno, unikatno ime consumerja če je prazno se generira avtomatsko, no_local, false (true consumer in publisher morata imeti ločen connection) no_ack, true → auto ack Exclusive, false (samo ta consumer?) no_wait, false, ali naj consumer čaka na odgovor z serverja callback