Rails:用运动鞋获取活动名称

时间:2017-01-10 19:49:34

标签: ruby-on-rails ruby ruby-on-rails-4

我有这段代码:

require 'json'

class PaymentEvents < Workers
  include Sneakers::Worker

  from_queue "my-queue",
    exchange: 'payment',
    exchange_type: :topic,
    exchange_options: { durable: true },
    queue_options: { durable: true },
    routing_key: 'event.payment.*',
    timeout_job_after: 120

  def internal_work(msg)
    #do stuff here, according to the type of the event

    ack!
  end

因为我的routing_key是&#34; event.payment。*&#34;,有没有办法确切知道接收的是什么事件?

1 个答案:

答案 0 :(得分:0)

我快速浏览了一下,看起来您可以实施work_with_params而不是work,并且您将传递其他参数。

参考https://github.com/jondot/sneakers/blob/9de1f485648d884036347c6bea81cf4d9edaa7b9/lib/sneakers/worker.rb#L57