Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

3

Share

Download to read offline

Queue System and Zend\Queue implementation

Download to read offline

PugMi for Queue System and implementation in PHP with Zend\Queue

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

Queue System and Zend\Queue implementation

  1. 1. http://twitter.com/GianArb Queue system gianarb92@gmail.com Gianluca Arbezzano 1 Gianluca Arbezzano @GianArb http://github.com/gianarb
  2. 2. http://twitter.com/GianArb TODO • Send a mail • Upload big file • Imports • Messagging • … gianarb92@gmail.com Gianluca Arbezzano 2
  3. 3. http://twitter.com/GianArb Only one Role gianarb92@gmail.com Gianluca Arbezzano 3 You DON’T MAKE to user wait
  4. 4. http://twitter.com/GianArb The solution is… gianarb92@gmail.com Gianluca Arbezzano 4
  5. 5. http://twitter.com/GianArb Queue System gianarb92@gmail.com Gianluca Arbezzano 5 • Queue • Producer • Consumer • Message
  6. 6. http://twitter.com/GianArb Queue gianarb92@gmail.com Gianluca Arbezzano 6 ZendQueueQueue // Create an array queue adapter $adapter = new ArrayAdapter(); // Create a queue object $queue = new Queue('queue1', $adapter); Adapter • Db • MongoDb • MongoCappedCollection • ArrayAdapter • TODO: Redis • TODO: RabbitMQ
  7. 7. http://twitter.com/GianArb Message Queue Message queues provide an asynchronous communications protocol, meaning that the sender and receiver of the message do not need to interact with the message queue at the same time. Cit. Wikipedia gianarb92@gmail.com Gianluca Arbezzano 7 ZendQueueMessageMessage implement ZendStdlibMessage
  8. 8. http://twitter.com/GianArb Producer • Send messages quickly gianarb92@gmail.com Gianluca Arbezzano 8 Consumer • Receive messages • Usually it’s a worker that consumes one message at time.
  9. 9. http://twitter.com/GianArb Queue System, when? gianarb92@gmail.com Gianluca Arbezzano 9 Registration Query Mail • Time-shifts job processing when the “CPU” is less busy • Distributed computing • In a web app allows to run tasks in background reducing the http request time
  10. 10. http://twitter.com/GianArb Workflow gianarb92@gmail.com Gianluca Arbezzano 10 Registration Query Send Message in queue Send mail Send mail Send mail Send mail Send mailWORKER
  11. 11. http://twitter.com/GianArb Worker (old way) use ZendQueueQueue; do { $messages = $queue->receive(); //do some work sleep(1); } while (…) gianarb92@gmail.com Gianluca Arbezzano 11
  12. 12. http://twitter.com/GianArb WORKERS! gianarb92@gmail.com Gianluca Arbezzano 12
  13. 13. http://twitter.com/GianArb Await gianarb92@gmail.com Gianluca Arbezzano 13 $queue->await()
  14. 14. http://twitter.com/GianArb Role • Your adapter implement awaitMessage() • || your queue can emulate await gianarb92@gmail.com Gianluca Arbezzano 14 $adapter->awaitMessages(Queue $queue, $callback, ReceiveParameters $params = null)
  15. 15. http://twitter.com/GianArb *callback gianarb92@gmail.com Gianluca Arbezzano 15
  16. 16. http://twitter.com/GianArb Worker use ZendQueueQueue; use ZendQueueQueueEvent; $queue->getEventManager()- >attach(QueueEvent::EVENT_RECEIVE, function (QueueEvent $e) use ($queue) { $message = $e->getMessages()->current(); //do some work $queue->delete($message); }); //Wait for incoming messages $queue->await(); gianarb92@gmail.com Gianluca Arbezzano 16
  17. 17. http://twitter.com/GianArb Use case overview • Short run jobs • Long run jobs • Schedule jobs (like cron jobs) • Enterprise service bus gianarb92@gmail.com Gianluca Arbezzano 17
  18. 18. http://twitter.com/GianArb Links! • Use case https://github.com/ripaclub/ZendQueue/wiki/ Example-Usage • Proposal https://github.com/ripaclub/ZendQueue/wiki/ ZendQueue-Proposal gianarb92@gmail.com Gianluca Arbezzano 18
  19. 19. http://twitter.com/GianArb Ripa Club gianarb92@gmail.com Gianluca Arbezzano 19 Powered by http://github.com/ripaclub
  • piccoloprincipe

    Oct. 12, 2016
  • HimanshuPatel13

    Sep. 9, 2014
  • tmquang6805

    May. 8, 2014

PugMi for Queue System and implementation in PHP with Zend\Queue

Views

Total views

2,667

On Slideshare

0

From embeds

0

Number of embeds

165

Actions

Downloads

10

Shares

0

Comments

0

Likes

3

×