3

I am using the JobProcessing, JobProcessed and JobFailed to populate a queue logs table.

I would like to also listen for an event as jobs are pushed to the queue. Does this exist?

I see from running:

\Redis::lrange('queues:mws', 0, -1)

That a pushedAt parameter exists, but I am unsure how to get this in an event prior to the job actually being processed.

This is fundamentally in order to check that my queues are all:

  • a) actually running (the workers have not stopped).
  • b) the job processing time is not too long.
2
  • I would like to also listen for an event as queues are pushed to the queue - confused by this. Did you mean you want to dispatch an event when a job is queued? Commented Feb 8, 2019 at 20:52
  • Sorry, I fixed my typo. I meant "listen for an event when jobs are pushed to the queue`. I was hoping laravel may dispatch an event every time a job is pushed (as it does when a job is processing, processed or failed). If laravel does not do this by default, is it possible for me to define this globally for all job dispatches? I know how to do this within each job class, but I would like to ensure its enabled by default for every push. Commented Feb 10, 2019 at 11:44

1 Answer 1

0

For anyone wondering, you can get this information when using horizon by listening for the JobPushed event. The payload for this event contains the job ID, name, connetion and queue etc.

Event::listen(JobPushed::class, function(JobPushed $event){
    \Log::debug('JobPushed Event Fired ', [
        'connection' => $event->connectionName,
        'queue' => $event->queue,
        'payload' => [
            'id' => $event->payload->id(),
            'displayName' => $event->payload->displayName(),
            'commandName' => $event->payload->commandName(),
            'isRetry' => $event->payload->isRetry(),
            'retryOf' => $event->payload->retryOf(),
        ]
    ]);
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.