Webador / SlmQueue

Laminas / Mezzio module that integrates with various queue management systems.
Other
137 stars 56 forks source link

Unsupported operand types #192

Closed davidwindell closed 6 years ago

davidwindell commented 7 years ago

I'm seeing the below error intermittently, not quite sure why (at https://github.com/juriansluiman/SlmQueue/blob/master/src/Queue/AbstractQueue.php#L65).

Error: Unsupported operand types
  File "vendor/slm/queue/src/Queue/AbstractQueue.php", line 65, in unserializeJob
    $metadata += $data['metadata'];
  File "vendor/slm/queue-doctrine/src/Queue/DoctrineQueue.php", line 177, in pop
    return $this->unserializeJob($row['data'], ['__id__' => $row['id']]);
  File "vendor/slm/queue/src/Strategy/ProcessQueueStrategy.php", line 46, in onJobPop
    $job          = $queue->pop($options);
  File "vendor/zendframework/zend-eventmanager/src/EventManager.php", line 322, in triggerListeners
    $response = $listener($event);
  File "vendor/zendframework/zend-eventmanager/src/EventManager.php", line 179, in triggerEventUntil
    return $this->triggerListeners($event, $callback);
...

$metadata is:

{
__id__: 862613
}
basz commented 7 years ago

hi

$metadata should not be an object

as [] += {} will fail.

do you use the new BinaryMessageInterface on your jobs?

What queue adapter are you using?

davidwindell commented 7 years ago

Hi @basz, it's the Doctrine Queue, the next step up in the stack track is at https://github.com/juriansluiman/SlmQueueDoctrine/blob/master/src/Queue/DoctrineQueue.php#L177.

basz commented 7 years ago

Which version?

'composer show'

And do you use the newly introduced binaryjobinterface on one of your jobs?

Op 3 feb. 2017 om 01:22 heeft David Windell notifications@github.com het volgende geschreven:

Hi @basz, it's the Doctrine Queue, the next step up in the stack track is at https://github.com/juriansluiman/SlmQueueDoctrine/blob/master/src/Queue/DoctrineQueue.php#L177.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

davidwindell commented 7 years ago
...
slm/queue                              v0.6.0
slm/queue-doctrine                      0.6.1
...

All jobs extend SlmQueueAbstractJob

basz commented 7 years ago

Ok so not the problem is not with latest release, which is good.

I have no idea why this error happens other then that the metadata is an object. Can you tell me if you do anything strange when creating a job? Or inside it and reading it. Do you use setting metadata yourself?

Additionally; it might be useful to inspect the data field in the db to deter main if it the push or the pop job side of things.

Op 3 feb. 2017 om 16:42 heeft David Windell notifications@github.com het volgende geschreven:

... slm/queue v0.6.0 slm/queue-doctrine 0.6.1 ... All jobs extend SlmQueueAbstractJob

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

basz commented 7 years ago

Did you have anymore info on this?

davidwindell commented 7 years ago

Could it be to do with the manual setting of the metadata in our Abstract Job? i.e. setMetadata?

<?php

namespace Zebreco\Job;

use SlmQueue\Job\AbstractJob as SlmQueueAbstractJob;
use SlmQueue\Queue\QueueAwareInterface;
use SlmQueue\Queue\QueueAwareTrait;

abstract class AbstractJob extends SlmQueueAbstractJob implements QueueAwareInterface
{
    use QueueAwareTrait;

    public function setRetries(int $retries)
    {
        $this->setMetadata('__retries__', $retries);
        return $this;
    }

    public function getRetries()
    {
        return $this->getMetadata('__retries__');
    }

    protected function retryJob(int $delay = 60)
    {
        $this->setRetries($this->getRetries() + 1);

        $this->getQueue()->push($this, [
            'delay' => $delay
        ]);
    }
}

The only other thing I can see is one of the array keys that we send to $job->setContent() is called "metadata" too.

basz commented 7 years ago

looking at Zend\Stdlib\Message that (metadata in content) should not be a problem.

I would suggest avoid using XXX as metadata keys. we use id for example, but there are others too. consider __ as private to slmQueue

basz commented 7 years ago

do you have the data of a payload that fails?

i don't understand how your metadata could be :

{
__id__: 862613
}

should atleast have a name too. see https://github.com/juriansluiman/SlmQueue/blob/master/src/Queue/AbstractQueue.php#L100

davidwindell commented 7 years ago

I'll get some detailed logging setup when I'm back from holiday in a week or so. Thanks!

roelvanduijnhoven commented 6 years ago

Any update on this @davidwindell? Have not heard anyone else or encountered this myself. Will close for now; but feel free to open if you have new info!