Module: TorqueBox::Messaging::Backgroundable::Util

Defined in:
messaging/lib/torquebox/messaging/backgroundable.rb

Class Method Summary (collapse)

Class Method Details

+ (Boolean) instance_methods_include?(klass, method)

Returns:

  • (Boolean)


227
228
229
230
# File 'messaging/lib/torquebox/messaging/backgroundable.rb', line 227

def instance_methods_include?(klass, method)
  methods_include?(klass.instance_methods, method) ||
    private_instance_methods_include?(klass, method)
end

+ (Boolean) methods_include?(methods, method)

Returns:

  • (Boolean)


240
241
242
243
# File 'messaging/lib/torquebox/messaging/backgroundable.rb', line 240

def methods_include?(methods, method)
  method = (RUBY_VERSION =~ /^1\.8\./ ? method.to_s : method.to_sym)
  methods.include?(method)
end

+ (Boolean) private_instance_methods_include?(klass, method)

Returns:

  • (Boolean)


232
233
234
# File 'messaging/lib/torquebox/messaging/backgroundable.rb', line 232

def private_instance_methods_include?(klass, method)
  methods_include?(klass.private_instance_methods, method)
end

+ (Boolean) private_singleton_methods_include?(klass, method)

Returns:

  • (Boolean)


219
220
221
# File 'messaging/lib/torquebox/messaging/backgroundable.rb', line 219

def private_singleton_methods_include?(klass, method)
  methods_include?(klass.private_methods, method)
end

+ (Boolean) protected_instance_methods_include?(klass, method)

Returns:

  • (Boolean)


236
237
238
# File 'messaging/lib/torquebox/messaging/backgroundable.rb', line 236

def protected_instance_methods_include?(klass, method)
  methods_include?(klass.protected_instance_methods, method)
end

+ (Boolean) protected_singleton_methods_include?(klass, method)

Returns:

  • (Boolean)


223
224
225
# File 'messaging/lib/torquebox/messaging/backgroundable.rb', line 223

def protected_singleton_methods_include?(klass, method)
  methods_include?(klass.protected_methods, method)
end

+ (Object) publish_message(receiver, method, args, options = { })



197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'messaging/lib/torquebox/messaging/backgroundable.rb', line 197

def publish_message(receiver, method, args, options = { })
  queue_name = Task.queue_name( "torquebox_backgroundable" )
  queue = Queue.new( queue_name )
  future = Future.new( queue )
  options[:encoding] = :marshal
  queue.publish( {:receiver => receiver,
                   :future_id => future.correlation_id,
                   :future_queue => queue_name,
                   :future_ttl => options[:future_ttl],
                   :method => method,
                   :args => args}, options )

  future
rescue javax.jms.InvalidDestinationException => ex
  raise RuntimeError.new("The Backgroundable queue is not available. Did you disable it by setting its concurrency to 0?")
end

+ (Boolean) singleton_methods_include?(klass, method)

Returns:

  • (Boolean)


214
215
216
217
# File 'messaging/lib/torquebox/messaging/backgroundable.rb', line 214

def singleton_methods_include?(klass, method)
  methods_include?(klass.singleton_methods, method) ||
    private_singleton_methods_include?(klass, method)
end