2017 © Pedro Peláez
 

library gearman

Gearman provider for queues in laravel4

image

pafelin/gearman

Gearman provider for queues in laravel4

  • Tuesday, November 14, 2017
  • by pafelin
  • Repository
  • 5 Watchers
  • 50 Stars
  • 9,672 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 17 Forks
  • 1 Open issues
  • 11 Versions
  • 4 % Grown

The README.md

Description

This package gives you the possibily to add gearman as native queue back-end service, (*1)

Installation

first you need to add it to your composer.json, (*2)

second, in config/app.php, you need to comment out the native queue service provider, (*3)

//'Illuminate\Queue\QueueServiceProvider',

and to put this instead:, (*4)

'Pafelin\Gearman\GearmanServiceProvider',

Then in your config/queue.php file you can add:, (*5)

'default' => 'gearman',
'connections' => array(
    'gearman' => array(
        'driver' => 'gearman',
        'host'   => 'localserver.6min.local',
        'queue'  => 'default',
        'port'   => 4730,
        'timeout' => 1000 //milliseconds
    )
)

or, if you have multiple gearman servers:, (*6)

'default' => 'gearman',
'connections' => array(
    'gearman' => array(
        'driver' => 'gearman',
        'hosts'  => array(
            array('host' => 'localserver.6min.local', 'port' => 4730),
            array('host' => 'localserver2.6min.local', 'port' => 4730),
        ),
        'queue'  => 'default',
        'timeout' => 1000 //milliseconds
    )
)

Then in your code you can add code as (this is the native way to add jobs to the queue):, (*7)

Queue::push('SomeClass', array('message' => 'The data that should be available in the SomeClass@fire method'));

Small hint, you can call Namespaced classes and everything that is written in the docs of laravel for calling custom methods is valid here, too., (*8)

Example:

I add a "service" folder to my app folder and inside I create a file "SendMail.php" The code of the class is here:, (*9)

<?php

namespace TaskProcess\Services;

class SendMail {

    public function fire($job, $data)
    {
        //I send an email to my email address with subject "gearman test" and message whatever comes from gearman
        mail('pavel@taskprocess.com', 'gearman test', $data['message']);
    }

}

In my routes file I add a new Route, (*10)

Route::get('/gearman', function() {
    //in a loop I add 3 jobs to gearman with different content. The purpose is to see 3 different emails with 3 different contents
    foreach (array(1,2,3) as $row) {
        Queue::push('TaskProcess\Services\SendMail', array('message' => 'Message №' . $row));
    }
});

Finally I just run on my console:, (*11)

php artisan queue:listen

And I go to check what's on my email, (*12)

Bugs

Please if you notice a bug open an issue or submit request., (*13)

Hope this package will help you, (*14)

The Versions

14/11 2017

dev-master

9999999-dev

Gearman provider for queues in laravel4

  Sources   Download

MIT

The Requires

 

by Pavel Genov

27/07 2017

0.3.3

0.3.3.0

Gearman provider for queues in laravel4

  Sources   Download

MIT

The Requires

 

by Pavel Genov

20/07 2017

0.3.2

0.3.2.0

Gearman provider for queues in laravel4

  Sources   Download

MIT

The Requires

 

by Pavel Genov

11/03 2016

0.3.1

0.3.1.0

Gearman provider for queues in laravel4

  Sources   Download

MIT

The Requires

 

by Pavel Genov

02/12 2015

0.3.0

0.3.0.0

Gearman provider for queues in laravel4

  Sources   Download

MIT

The Requires

 

by Pavel Genov

13/04 2015

0.2.5

0.2.5.0

Gearman provider for queues in laravel4

  Sources   Download

MIT

The Requires

 

by Pavel Genov

16/03 2015

0.2.4

0.2.4.0

Gearman provider for queues in laravel4

  Sources   Download

MIT

The Requires

 

by Pavel Genov

13/03 2015

0.2.2

0.2.2.0

Gearman provider for queues in laravel4

  Sources   Download

MIT

The Requires

 

by Pavel Genov

13/03 2015

0.2.3

0.2.3.0

Gearman provider for queues in laravel4

  Sources   Download

MIT

The Requires

 

by Pavel Genov

13/03 2015

0.2.1

0.2.1.0

Gearman provider for queues in laravel4

  Sources   Download

MIT

The Requires

 

by Pavel Genov

22/09 2014

0.2.0

0.2.0.0

Gearman provider for queues in laravel4

  Sources   Download

MIT

The Requires

 

by Pavel Genov