Hacker News new | ask | show | jobs
by marceldegraaf 5109 days ago
I think the main reason for this is that strange things can happen when you're passing marshalled objects around. For instance, say that your application has just created an Email object which has a "title" attribute, and it has been marshalled and put it into a queue. Your queue is a bit full, so it takes a while for the email to be processed. Right after it has been enqueued, you roll out an update to your code, changing the "title" field to be called "subject". As soon as your Email object is pulled from the queue, you will get NoMethodErrors from your asynchronous mailer code because the unmarshalled object doesn't have a "subject" method yet.

The reason queueing systems like Resque and Sidekiq pass id's around (instead of objects) is to make sure that the asynchronous worker always has a fresh object straigh from the data store. I guess that's why Rails core has decided to implement it like this as well.