Class: TorqueBox::Messaging::BackgroundableProcessor

Inherits:
MessageProcessor show all
Defined in:
lib/torquebox/messaging/backgroundable_processor.rb

Instance Attribute Summary

Attributes inherited from MessageProcessor

#message

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from MessageProcessor

#initialize, #on_error, #process!

Methods included from ProcessorMiddleware::DefaultMiddleware

default

Constructor Details

This class inherits a constructor from TorqueBox::Messaging::MessageProcessor

Class Method Details

.log_newrelic_notice(klass) ⇒ Object



26
27
28
29
30
# File 'lib/torquebox/messaging/backgroundable_processor.rb', line 26

def self.log_newrelic_notice(klass)
  @newrelic_notice_logged ||=
    log.warn( "The New Relic agent is loaded, but an issue with the inheritance hierachy of " <<
              klass.name << " prevents us from reporting on its Backgroundable calls." ) || true
end

Instance Method Details

#middlewareObject

Do not begin a transaction before invoking a Backgroundable method



46
47
48
# File 'lib/torquebox/messaging/backgroundable_processor.rb', line 46

def middleware
  super.remove(TorqueBox::Messaging::ProcessorMiddleware::WithTransaction)
end

#on_message(hash) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/torquebox/messaging/backgroundable_processor.rb', line 32

def on_message(hash)
  FutureResponder.new( Queue.new( hash[:future_queue] ), hash[:future_id] ).respond do
    klass = hash[:receiver].class
    if klass.respond_to?( :__enable_backgroundable_newrelic_tracing )
      klass.__enable_backgroundable_newrelic_tracing( hash[:method] )
    elsif Backgroundable.newrelic_available? 
      self.class.log_newrelic_notice( klass )
    end
    
    hash[:receiver].send(hash[:method], *hash[:args])
  end
end