Browse files

make :exchange_alerts amqp config optional

  • Loading branch information...
1 parent 5fc3b49 commit 2666cfd3752dbed41c153c1e0cee948df4006a30 @fetep committed Apr 29, 2012
Showing with 10 additions and 6 deletions.
  1. +10 −6 lib/cepmon/eventlistener.rb
View
16 lib/cepmon/eventlistener.rb
@@ -21,11 +21,15 @@ def initialize(engine, config)
@alerts = {}
@history = []
- @amqp = Bunny.new(@config.amqp)
- @amqp.start
- @exchange = @amqp.exchange(@config.amqp[:exchange_alerts],
- :type => :topic,
- :durable => true)
+ if @config.amqp[:exchange_alerts]
+ @amqp = Bunny.new(@config.amqp)
+ @amqp.start
+ @exchange = @amqp.exchange(@config.amqp[:exchange_alerts],
+ :type => :topic,
+ :durable => true)
+ else
+ @exchange = nil
+ end
end
public
@@ -61,7 +65,7 @@ def record_alert(vars, statement_name, exchange)
@alerts[key].update(vars)
else
alert = CEPMon::Alert.new(vars)
- exchange.publish(alert.to_json)
+ exchange.publish(alert.to_json) if exchange
@alerts[key] = alert
@history << alert
end

0 comments on commit 2666cfd

Please sign in to comment.