Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not an issue don't flag it! Missed something in the great doc #36

Open
mdjaman opened this issue Jul 11, 2015 · 2 comments
Open

Not an issue don't flag it! Missed something in the great doc #36

mdjaman opened this issue Jul 11, 2015 · 2 comments

Comments

@mdjaman
Copy link

mdjaman commented Jul 11, 2015

Hi as mentioned in the title is not an issue, have an php app in which i put some job via https://github.com/pda/pheanstalk/

$pheanstalk
            ->useTube('testtube')
            ->put(json_encode(array('hello' => 'mdjaman')));

then i want fivebeans worker to process the job; unfornatedly i missed something in documentation.
Can someone point me to right track

@JoshWillik
Copy link

@mdjaman You didn't really explain what your problem is.

Would you not use something like the following?

client.watch('testtube', watchErr => {
  if (watchErr) console.log(watchErr)
  client.reserve((err, jobId, rawPayload) => {
    var payload = JSON.parse(rawPayload.toString())
    // Process `payload` here
  })
})

@naffiq
Copy link

naffiq commented Mar 24, 2017

@mdjaman

Encountered same issue with putting jobs from PHP. It turned out, that fivebeans uses it's format of payload.

To make it work, i actually had to format it on PHP side:

$beanstalk->putInTube('testtube', [
    'testtube', // Tube name has to be in the payload as well
    [
        'type' => 'handler-type', // Handler key defined in JS's options object
        'payload' => $payload // Here goes actual data that worker will receive
    ]
], $priority, $delay);

And my JS code is

var Beanworker = require('fivebeans').worker;
var options =
{
    id: 'my_worker',
    host: '127.0.0.1',
    port: 11300,
    handlers:
    {
        'handler-type': notifier // 'type' in PHP code
    },
    ignoreDefault: true
}
var worker = new Beanworker(options);

worker.start(['testtube']);

I know this issue is old, but hope that helps anyone.
Maybe we really should cover it in Docs though? @ceejbot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants