
Untitled
By: a guest on
Aug 19th, 2012 | syntax:
None | size: 0.88 KB | hits: 12 | expires: Never
# you'll need to create a queue for the future messages.
# here I'll use one called '/queue/futures'
# on the 'client' side:
correlation_id = 'some unique id'
future = TorqueBox::Messaging::Future.new( '/queue/futures', :correlation_id => correlation_id )
message = { :some => 'data', :id => correlation_id }
@some_queue.publish( message )
#in the processor for @some_queue:
TorqueBox::Messaging::FutureResponder.new( '/queue/futures', :correlation_id => message[:id]).respond do
# do the processing here - started, error, and the final return value will automatically be sent to the future
# you can update the future status via:
future.status = 123
# return a value
my_computed_value
end
# docs for Future: http://torquebox.org/2x/builds/yardocs/TorqueBox/Messaging/Future.html
# docs for FutureResponder: http://torquebox.org/2x/builds/yardocs/TorqueBox/Messaging/FutureResponder.html