如何订购resque流程作业

时间:2012-06-04 17:57:14

标签: ruby ruby-on-rails-3 resque

我有一个队列处理一些'产品'thar是通过JSON发送的。我按照{1,2,3,4}的顺序接收它们,但是在{1,3,2,4}中重新处理它们。由于旧版Product可以覆盖已经处理过的新版本,因此他们订购的resque流程非常重要。 有没有办法告诉像process {job} orderede by {job.field_I_want}这样的resque?

编辑:排队作业的代码

def produto
        if params[:json]
#          upload = params[:json]
#          content = upload.read
#          parsed_json = JSON(content)

          parsed_json = JSON(params[:json])
          parsed_json['idFila'] = params[:idFila]

          logger.info parsed_json

          Resque.enqueue(ProdutoWorker, parsed_json)
          render json: ActiveSupport::JSON.encode(Retorno.new(:status => "OK", :mensagem => "Produto recebido")), :status => :ok
        else
          render json: ActiveSupport::JSON.encode(Retorno.new(:status => "Erro", :mensagem => "Sem JSON")), :status => :not_found
        end

        rescue => exception
          render json: ActiveSupport::JSON.encode(Retorno.new(:status => "Erro", :mensagem => "#{exception}")), :status => :error
      end #Produto

1 个答案:

答案 0 :(得分:0)

resque按照排队的顺序处理作业,你可以发布排队作业的代码吗?