Class: EventPeople::Broker::Rabbit

Inherits:
Base
  • Object
show all
Defined in:
lib/event_people/broker/rabbit.rb

Defined Under Namespace

Classes: Queue, RabbitContext, Topic

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

consume, consumers, produce

Class Method Details

.close_connectionObject



18
19
20
# File 'lib/event_people/broker/rabbit.rb', line 18

def self.close_connection
  @@connection.close
end

Instance Method Details

#connectionObject



4
5
6
# File 'lib/event_people/broker/rabbit.rb', line 4

def connection
  @@connection ||= session
end

#consume(event_name, &block) ⇒ Object



8
9
10
# File 'lib/event_people/broker/rabbit.rb', line 8

def consume(event_name, &block)
  Queue.subscribe(channel, event_name, &block)
end

#produce(events) ⇒ Object



12
13
14
15
16
# File 'lib/event_people/broker/rabbit.rb', line 12

def produce(events)
  events.each do |event|
    Topic.produce(channel, event)
  end
end