我正在开发一个发送电子邮件,新注册等的Rails 4应用程序,我正在尝试设置SQS
以使用deliver_later
通过队列处理它们。在开发中,我使用Fake_SQS来模拟这一点。
消息正在成功添加到队列中。如果我使用binding.pry
我得到(格式很好)。
resp = sqs.receive_message({queue_url: "http://localhost:4568/mailers"}) =>
#<struct Aws::SQS::Types::ReceiveMessageResult
messages = [#<struct Aws::SQS::Types::Message
message_id="95c380c7-9710-449e-beb6-19b19cc88e04",
receipt_handle="7b51a9568a6301509459697376e867a6",
md5_of_body="d09027c2c92b19e572766360fc627630",
body="{\"job_class\" : \"ActionMailer::DeliveryJob\",
\"job_id\" : \"6edb612c-e5f7-4cc0-8236-4ac538344c66\",
\"queue_name\" : \"mailers\",
\"arguments\" : [\"UserMailer\",
\"test_email\",
\"deliver_now!\",
null],
\"locale\" : \"en\"}",
attributes={},
md5_of_message_attributes=nil,
message_attributes={}>]>
我遇到的问题是稍后发送这些电子邮件。我想我必须启动ActiveJob工作者,但我认为在使用deliver_later
时会自动启动。如果没有,我该如何启动它并将其正确地指向我的队列?
答案 0 :(得分:3)
将以下内容添加到config/environments/development.rb
:
config.active_job.queue_adapter = :inline