Class: BrmClient::Gateway::Amqp

Inherits:
Object
  • Object
show all
Defined in:
lib/brm_client/gateway/amqp.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Amqp

Returns a new instance of Amqp.



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/brm_client/gateway/amqp.rb', line 8

def initialize opts
  @connection = Bunny.new({
    :logging => opts[:logging] || false,
    :host => opts[:host] || "localhost",
    :port => opts[:port] || 5672,
    :user => opts[:user] || "guest",
    :pass => opts[:pass] || "guest",
    :vhost => opts[:vhost] || "/"
  })
  
  @connection.start
  @queue = @connection.queue "reactor.#{opts[:application]}"
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



6
7
8
# File 'lib/brm_client/gateway/amqp.rb', line 6

def connection
  @connection
end

#queueObject (readonly)

Returns the value of attribute queue.



6
7
8
# File 'lib/brm_client/gateway/amqp.rb', line 6

def queue
  @queue
end

Instance Method Details

#disconnectObject



22
23
24
# File 'lib/brm_client/gateway/amqp.rb', line 22

def disconnect
  @connection.stop
end

#send_event(e) ⇒ Object



26
27
28
# File 'lib/brm_client/gateway/amqp.rb', line 26

def send_event e
  @queue.publish(e.to_json)
end