Class: BrmClient::Gateway::Amqp
- Inherits:
-
Object
- Object
- BrmClient::Gateway::Amqp
- Defined in:
- lib/brm_client/gateway/amqp.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
Instance Method Summary collapse
- #disconnect ⇒ Object
-
#initialize(opts) ⇒ Amqp
constructor
A new instance of Amqp.
- #send_event(e) ⇒ Object
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
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
6 7 8 |
# File 'lib/brm_client/gateway/amqp.rb', line 6 def connection @connection end |
#queue ⇒ Object (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
#disconnect ⇒ Object
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 |