On 15 Jun 2011, at 18:25, Justin Stanczak wrote:
Yes, I'm starting to learn this. When I say distributed, I mean I'm
linking applications with rabbitmq and ruby amqp. I then pass a
message that's serialized in json. The issue is normal integer id's
between apps will clash, so I was going to use uuid as the id
instead.I'm guessing you are saying make the uuid another field, and
just update the object. So the two applications would maintain their
own id's, but match uuid's? Is there not a method of doing this that
already works. I know I'm not the first to pass objects around.
That's exactly how we do it using Nanite. Nanite gives us a unique
identifier (some hash like yours), we store it in the database with
the record that will be affected, then search for that hash when the
callback fires with the processed data. Nothing too complicated there.
At the end of your callback function, you set the hash field to NULL
so it no longer occupies space.
Something like this:
report = Report.new
report.uid = Nanite.request('/report/generate', report[:json_data],
&NaniteCallbacks.report)
def NaniteCallbacks.report
lambda do |res|
uid = res[res.keys.first]
report.find_by_uid(uid).update_attributes!(res)
end
end
That's the gist of it basically (it's a bit more complicated in our
application, but you get the point).
Best regards
Peter De Berdt
--
You received this message because you are subscribed to the Google Groups "Ruby on
Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.