• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Queue System and Zend\Queue implementation
 

Queue System and Zend\Queue implementation

on

  • 421 views

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

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

Statistics

Views

Total Views
421
Views on SlideShare
327
Embed Views
94

Actions

Likes
1
Downloads
1
Comments
0

3 Embeds 94

http://www.scoop.it 70
https://twitter.com 20
http://www.slideee.com 4

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Queue System and Zend\Queue implementation Queue System and Zend\Queue implementation Presentation Transcript

    • http://twitter.com/GianArb Queue system gianarb92@gmail.com Gianluca Arbezzano 1 Gianluca Arbezzano @GianArb http://github.com/gianarb
    • http://twitter.com/GianArb TODO • Send a mail • Upload big file • Imports • Messagging • … gianarb92@gmail.com Gianluca Arbezzano 2
    • http://twitter.com/GianArb Only one Role gianarb92@gmail.com Gianluca Arbezzano 3 You DON’T MAKE to user wait
    • http://twitter.com/GianArb The solution is… gianarb92@gmail.com Gianluca Arbezzano 4
    • http://twitter.com/GianArb Queue System gianarb92@gmail.com Gianluca Arbezzano 5 • Queue • Producer • Consumer • Message
    • 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
    • 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
    • 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.
    • 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
    • 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
    • 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
    • http://twitter.com/GianArb WORKERS! gianarb92@gmail.com Gianluca Arbezzano 12
    • http://twitter.com/GianArb Await gianarb92@gmail.com Gianluca Arbezzano 13 $queue->await()
    • 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)
    • http://twitter.com/GianArb *callback gianarb92@gmail.com Gianluca Arbezzano 15
    • 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
    • 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
    • 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
    • http://twitter.com/GianArb Ripa Club gianarb92@gmail.com Gianluca Arbezzano 19 Powered by http://github.com/ripaclub