GearmanPHP

Laravel4 Queue with Gearman

Hi all , this article about Laravel4 Queue component.

Before,  start reading this article please check these pages and get basic knowledge about it.

  1. Laravel 4.2 Queue Documentation
  2. What’s main idea of Queue system and why do we need this?
  3. What is Gearman Job Server?

If you are interested in Laravel 4 Queue component , you’ll have good options for Job Server like;

These are supported in Laravel Default Framework..

What should I pay attention while choosing  Job Server Platform?

  •  Most important thing is your volume. How many job will handle with this server ?
  •  How much time is going to be completed for standart one task?
  • Do you need cross-platform integration in your application ? Like Php based system and Java Based Compression Tool etc..

If you have only hardware(not enough CPU , RAM) problems  , I suggest you to buy a service from Amazon or IronMQ.

or If you just need quickness and velocity for visitors. You’ve to deal with local solutions. Redis , IronMQ  etc..

As you know , Sometimes its not possible solve everyting with one language and you’d need Hybrid solutions. Then we are talking about Gearman 😀

Just select your language..

Gearman Support Famous Languages

Please check this site for documentation and more indormation

  • PHP
  • Mysql
  • Java
  • Go
  • C#
  • Node.js

It’s not complicated to develop Hybrid Solutions with Gearman.

Setup Gearman into Server

  • apt-get install gearman-job-server
    
    gearmand -d

    For other Operating Systems  check this page.

Gearman Integration with Laravel Queue

This bundle is very easy to integrate Gearman with Laravel : Github Link

Thanks for useful github project.

If you succesfully added Gearman bundle into your project , Now you can check queue list by laravel command line.

  • php artisan queue:listen

Do not forget to Setup Gearman Monitoring UI

  • git clone git://github.com/gaspaio/gearmanui.git gearman-ui
  • cd gearman-ui
    composer install
  •  cp app/config/gearmanui.yml.dist app/config/gearmanui.yml

Project :  This opensource project definetily monitoring basic info about Gearman Server. That’s exactly what I need. You can find more specific monitors if you need it.

What about Laravel Queue Trick

I love default routing for Fail or Exceptions. It’s very necesary in real-time actions.

  • php artisan queue:failed-table
    php artisan migrate
    

Let say you are using Local Solution as a Job Server and it Crashed. We’ve to handle this kind of situations. Laravel doing this for you just add the above part. Laravel save failed jobs into  Mysql->’failed-table’ That’s it..

  • Queue::failing(function($connection, $job, $data)
    {
        //OMG My Server Crashed or Something wrong send me an email right now!!!
    });

    With this routing we’ll be able to in touch our Job Server.

Muharrem Tığdemir

Author

Muharrem Tığdemir

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.