Class: TorqueBox::Messaging::Task Private
- Inherits:
-
Object
- Object
- TorqueBox::Messaging::Task
- Defined in:
- lib/torquebox/messaging/task.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Class Method Summary collapse
- .async(method, payload = {}, options = {}) ⇒ Object private
- .queue_name(name = self.name[0...-4]) ⇒ Object private
Instance Method Summary collapse
- #process!(message) ⇒ Object private
Methods included from ProcessorMiddleware::DefaultMiddleware
Methods included from FutureStatus
Class Method Details
.async(method, payload = {}, options = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/torquebox/messaging/task.rb', line 37 def self.async(method, payload = {}, = {}) queue = Queue.new( queue_name ) future = Future.new( queue ) = { :method => method, :payload => payload, :future_id => future.correlation_id, :future_queue => queue_name, :future_ttl => [:future_ttl] } [:encoding] = :marshal queue.publish( , ) future rescue javax.naming.NameNotFoundException => ex raise RuntimeError.new("The queue for #{self.name} is not available. Did you disable it by setting its concurrency to 0?") end |
.queue_name(name = self.name[0...-4]) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
32 33 34 35 |
# File 'lib/torquebox/messaging/task.rb', line 32 def self.queue_name( name = self.name[0...-4] ) suffix = org.torquebox.core.util.StringUtils.underscore(name) "/queues/torquebox/#{ENV['TORQUEBOX_APP_NAME']}/tasks/#{suffix}" end |
Instance Method Details
#process!(message) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
55 56 57 58 59 60 |
# File 'lib/torquebox/messaging/task.rb', line 55 def process!() hash = .decode FutureResponder.new( Queue.new( hash[:future_queue] ), hash[:future_id], hash[:future_ttl] ).respond do self.send hash[:method].to_sym, hash[:payload] end end |