Skip to content

"php artisan queue:retry" command is not working with MongodbQueueServiceProvider #1373

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

Closed
hamisor opened this issue Nov 23, 2017 · 0 comments

Comments

@hamisor
Copy link

hamisor commented Nov 23, 2017

Hi,

It appears that retrying failed jobs, using mongodb, does not work. I configured my environment as described in (https://github.com/jenssegers/laravel-mongodb#queues), project versions below:

"laravel/framework":     v5.4.36
"jenssegers/mongodb":    v3.2.3
"fhteam/laravel-amqp":   dev-master
mongodb v3.4

The error I receive is:

[ErrorException]                      
  Trying to get property of non-object 

The Laravel RetryCommand->retryJob($job) function is expecting the $job param to be a stdClass (instead of an array).

When using mongo, under the hood the MongoFailedJobProvider class (from MongodbQueueServiceProvider) calls the find() function to retrieve a single failed job, which returns an array (instead of an stdClass).

This type mismatch appears to be the problem.

A similar problem exists at (#1059) - namely, the laravel-mongodb query builder returns an array rather than an stdClass when performing db operations such as find(), get() first(), etc.

A quick fix I would suggest would be to make MongodbQueueServiceProvider work with the Laravel queue command, by casting inside the find() function in the MongoFailedJobProvider class, like so:

   /**
     * Get a single failed job.
     *
     * @param  mixed $id
     * @return stdClass
     */
    public function find($id)
    {
        $job = $this->getTable()->find($id);

        $job['id'] = (string) $job['_id'];

        // CAST HERE
        return (object)$job;
    }

@jenssegers, I would appreciate any suggestions on the proposed fix, I am happy to make a pull request for it.

Thanks

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

No branches or pull requests

2 participants