Support the ongoing development of Laravel.io →
posted 9 years ago
Queues
Last updated 2 years ago.
0

same stuff here, still trying to figure out how to delete delayed job. you're right the key is a big json object, and I can't just recreate same big json object as a key

0

I think it could be done with ZSCAN where you scan for that job json and at the end ignore the attempts probably. luckily my object is not so big, passing like 4 primary keys only. you're doing something wrong if you pass whole email template. you should pass only path to your blade email template file. will try to implement it tomorrow and post my results

0

Here it is

	/**
	 * @param $job_id
	 * @param string $queue is optional, if not passed then using 'default' queue
	 *
	 * @return int 1 if removed, 0 if not removed
	 */
	public static function deleteDelayedJob($job_id, $queue = 'default') {
		$redis_queue_instance = Queue::getRedis();
		// use redis ZSCAN with MATCH to find by pattern, its similar to SQL LIKE %jobid%
		$res = $redis_queue_instance->zscan('queues:'.$queue.':delayed', 0, 'MATCH', "*$job_id*");
		if ($res) { // make sure result is found
			if (isset($res[1])) { // first element is cursor, second is array with result
				$job_arr = $res[1];
				if (isset($job_arr[0])) { // make sure second element is array and has index 0
					$job = $job_arr[0]; // get the job id
					// remove the job which is literally removing element from Sorted Set
					return $redis_queue_instance->zrem('queues:'.$queue.':delayed', $job);
				}
			}
		}
		return 0; // not removed
//		throw new RuntimeException("Job id: $job_id not found for queue: $queue");
	}
Last updated 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

ian-p ian-p Joined 27 Oct 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.