Activejob无法反序列化对象

时间:2015-02-17 12:28:32

标签: ruby-on-rails sidekiq rails-activejob

要测试我的邮件是否正在发送,我正在运行heroku run rails c -a my_app。然后我把这项工作列入队伍并且入队了。但是,当我去Redis并看到排队的工作时,工作就不存在了。相反,它正在“重试”。

这就是我所看到的:

{"retry":true,"queue":"default","class":"ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper","args":[{"job_class":"SendMailJob","job_id":"4b4ba46f-94d7-45cd-b923-ec1678c73076","queue_name":"default","arguments":["any_help",{"_aj_globalid":"gid://gemfeedapi/User/546641393834330002000000"}]}],"jid":"f89235d7ab19f605ed0461a1","enqueued_at":1424175756.9351726,"error_message":"Error while trying to deserialize arguments: \nProblem:\n Document(s) not found for class User with id(s) 546641393834330002000000.\nSummary:\n When calling User.find with an id or array of ids, each parameter must match a document in the database or this error will be raised. The search was for the id(s): 546641393834330002000000 ... (1 total) and the following ids were not found: 546641393834330002000000.\nResolution:\n Search for an id that is in the database or set the Mongoid.raise_not_found_error configuration option to false, which will cause a nil to be returned instead of raising this error when searching for a single id, or only the matched documents when searching for multiples.","error_class":"ActiveJob::DeserializationError","failed_at":1424175773.317896,"retry_count":0}

但是,对象位于数据库中。

我尝试添加after_create回调(Mongoid),但没有任何区别。

有关正在发生的事情的任何想法吗?

感谢。

2 个答案:

答案 0 :(得分:13)

Sidekiq如此之快,以至于它在数据库提交事务之前执行您的工作。使用after_commit创建作业。

答案 1 :(得分:0)

好的,我的错。您需要启动一个新的Heroku Worker Dyno才能使Sidekiq工作(它不会自动执行)。