Giter Club home page Giter Club logo

laravel-gearman's Introduction

Description

This package gives you the possibily to add gearman as native queue back-end service

#Installation

first you need to add it to your composer.json

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

//'Illuminate\Queue\QueueServiceProvider',

and to put this instead:

'Pafelin\Gearman\GearmanServiceProvider',

Then in your config/queue.php file you can add:

'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:

'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):

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.

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:

<?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('[email protected]', 'gearman test', $data['message']);
    }

}

In my routes file I add a new Route

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:

php artisan queue:listen

And I go to check what's on my email

#Bugs

Please if you notice a bug open an issue or submit request.

Hope this package will help you

laravel-gearman's People

Contributors

bjdelange avatar nikola-barac avatar pafelin avatar pavel-pepper avatar websmurf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-gearman's Issues

[ReflectionException] Class TaskProcess\Services\SendMail does not exist

I have setup this up per the README.md on L4.2. When I push to the queue, I see the queue grow in gearadmin --status. However the tasks always fail. Running artisan queue:work shows this:

screenshot 2015-03-11 01 36 21

This is the directory where the SendEmail class is located.

ls -l app/service/
total 8
-rw-r--r-- 1 vagrant vagrant 327 Mar 11 05:21 GearmanTest.php
-rw-r--r-- 1 vagrant vagrant 487 Mar 11 05:29 SendMail.php

Is there something missing from the docs that I do not see.

Worker in daemon mode

Hi

I use laravel 5.2. When I run the queue with the following command

php artisan queue:work --daemon

gearadmin --status shows after some time that there are 200 instances of the worker running.

Also I'm seeing "1 minutes have elapsed, expiring."

That doesn't seem to be right?

Can you help?

Thanks

Sebo

Gearman with Laravel Complete working

Hi Team,

Thanks for your wounder full package. But one to get started with it and the complete working with laravel is quite a lengthy for any newbie like me. I would like to write a complete documentation on gearman from installation to working and usability and up-to production usage. All in one place. To achieve this will i get any assist from your side. Please make this issue as Question. Waiting for your reply.

Thank You.

Integration Request

Hi,

I'm pretty new to laravel development and I would like to install gearman job server in my laravel application with uses version 4.2 on ubuntu distribution with php5.6 but I'can't figure out string to be added to my composer.json to complete laravel integration

Sorry, for asked stupid question but I am stacked any where I can't continue a lotof tutorials described how to install gearman and the server setup is ready I can run job using CLI tools but now I need te full integration into my application

Please, HELP !!!!!!!!!!!!!!!!!!!!!!!

Laravel 5 doesn't use QueueInterface

GearmanQueue uses QueueInterface that isn't available in laravel 5 anymore. The new class and namespace is 'Illuminate\Contracts\Queue\Queue'

I forked the repo, and will send off a pull request for this later tonight.

Do not use PHP

PHP is terrible. Use something better, logo is great alternative :)

Class 'GearmanClient' not found

I have setup what you have mention in the docs but after that its shows in GearmanConnector.php (line 17) Class 'GearmanClient' not found ??

GearmanJob throwing exception

I get this error every time I try to add a job to the the Gearman queue

production.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Class 'Whoops\Example\Exception' not found' in /Applications/XAMPP/xamppfiles/htdocs/examprep/vendor/pafelin/gearman/src/Pafelin/Gearman/Jobs/GearmanJob.php:47

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.