Class: Cpi::Connector
- Inherits:
-
Object
- Object
- Cpi::Connector
- Defined in:
- lib/cpi/connector.rb
Instance Method Summary collapse
-
#initialize(params = {}, logger) ⇒ Connector
constructor
A new instance of Connector.
- #test_connectivity ⇒ Object
- #transmit(message, options = nil) ⇒ Object
Constructor Details
#initialize(params = {}, logger) ⇒ Connector
Returns a new instance of Connector.
6 7 8 9 10 |
# File 'lib/cpi/connector.rb', line 6 def initialize params={}, logger @queue = params.delete(:queue) @params = params @logger = logger end |
Instance Method Details
#test_connectivity ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/cpi/connector.rb', line 24 def test_connectivity @started = false start "Event Connector can connect to AMQP server at #{@params[:host]}:#{@params[:port]}" rescue StandardError => e e. end |
#transmit(message, options = nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/cpi/connector.rb', line 12 def transmit(, = nil) ||= {} [:before_retry] = lambda { @started = false } with_retries do start queue = [:queue] || @queue @exchange.publish(, :key => queue, :persistent => true) @bunny.tx_commit end end |