mwillbanks / MwGearman

Gearman Module for ZF2
20 stars 7 forks source link

Unable to get an instance of gearman #2

Closed nkrivokapic closed 11 years ago

nkrivokapic commented 11 years ago

I'm trying to get an instance of Gearman Worker (same problem exists with Gearman Client too). I've added DI config as in the README file. I'm using ZF2 with composer. After I run the following code:

$serviceLocator = $this->getServiceLocator(); try { $gearman = $serviceLocator->get('mwGearman\Worker\Pecl'); $gearman->register('ensureInstanceIsStarted', array($this, 'ensureXlInstanceIsUpWorkerFunction')); $gearman->connect();

        while($gearman->work());
    } catch (Exception $e) {
        print_r($e->getMessage() . PHP_EOL);
    }

I get an Exception with message:

An abstract factory could not create an instance of mwgearmanworkerpecl(alias: mwGearman\Worker\Pecl).

Any help is more then welcome :) Thanks.

mwillbanks commented 11 years ago

I'm guessing that you have figured this out?

nkrivokapic commented 11 years ago

Yep - sorry for missing the explanation. Problem was that gearman was not installed on my system (I've installed it on VM but forgot to install it on local server). It's fixed now.

tatanasova commented 10 years ago

Hi Mike, I am trying to get this installed and configured, but I think I am having trouble with setting up the DI. Where do I put it? I have it in my autoload/config as mwgearman.local.php, with server param set as is as localhost. When I do try to get an client and connect: $gearman = $this->getServiceLocator()->get('mwGearman\Client\Pecl');
$gearman->connect();

I get "you must add servers prior to connecting" exception, which is probably because its not getting the DI config correctly. What am I doing wrong?

tatanasova commented 10 years ago

I was able to resolve this by removing the invokables in the application config.. thanks