查找并删除延迟的重新创建作业 [英] Locating and removing a delayed resque job

查看:54
本文介绍了查找并删除延迟的重新创建作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一份重新启动的工作,它陷入了一些糟糕的代码中,并且在反复故障转移后无限地被请求.我想以某种方式手动删除作业,但我不确定 redis 命名空间中的作业名称.它不是失败",因为我正在捕获实际的异常.在例外情况下,我使用 Resque.enqueue_in() 将作业添加回 resque 队列.我如何找出 redis 中作业的名称,以便我可以从发生的事情中删除键/作业?

I have a resque job that got caught up in some bad code and is infinitely getting reque'd after failing over repeatedly. I'd like to remove the job manually, somehow, but I'm not sure what the name of the job is in the redis namespace. It isn't in 'failed' because I'm catching the actual exception. In the exception, I add the job back to the resque queue using Resque.enqueue_in(). How do I figure out what the name of the job is in redis so I can delete the key/job from ever happening?

推荐答案

Resque poll a redis list 本质上是一个队列 如果你想从 redis 中删除一条消息,那么你可以试试这个

Resque poll a redis list that essentially a queue if you want to remove a message from the redis then you can try this

require "rubygems"
require "redis"
require 'redis/namespace'
redis = Redis.new
namespace ||= :resque

@redis = Redis::Namespace.new(namespace, :redis => redis)
## If you dont know how does the job payload look like then find inside the list
## normally the payload look like this 
## {'class' => 'ProcessCSV' , args => ['1'] }.to_json.inpsect 
list_job_payloads = @redis.lrange "queue:[my queue name]",0,-1

## then finally remove from the list
@redis.lrem "queue:[my_queue_name]",0,value

但我想更好的方法是通过这样的 resque 删除作业

But I guess more better approach would be to delete the job via resque like this

考虑到以下是通过 resque 推送到您的 redis 列表的作业负载

Considering that the below is the job payload push to your redis list by resque

 { 'class' => 'ProcessCSV', 'args' => ['1'] }

然后你可以使用

 Resque::Job.destroy(queue, 'ProcessCSV', '1')

它还详细描述了这里

这篇关于查找并删除延迟的重新创建作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆