Class: RabbitMqSubscriptionManager

Inherits:
Object
  • Object
show all
Defined in:
lib/eventq_rabbitmq/rabbitmq_subscription_manager.rb

Instance Method Summary collapse

Constructor Details

#initializeRabbitMqSubscriptionManager

Returns a new instance of RabbitMqSubscriptionManager.



3
4
5
6
7
# File 'lib/eventq_rabbitmq/rabbitmq_subscription_manager.rb', line 3

def initialize
  @client = RabbitMqQueueClient.new
  @queue_manager = RabbitMqQueueManager.new
  @event_raised_exchange = EventRaisedExchange.new
end

Instance Method Details

#subscribe(event_type, queue) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/eventq_rabbitmq/rabbitmq_subscription_manager.rb', line 9

def subscribe(event_type, queue)

  channel = @client.get_channel
  queue = @queue_manager.get_queue(channel, queue)
  exchange = @queue_manager.get_exchange(channel, @event_raised_exchange)

  queue.bind(exchange, :routing_key => event_type)
end

#unsubscribe(queue) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/eventq_rabbitmq/rabbitmq_subscription_manager.rb', line 18

def unsubscribe(queue)

  channel = @client.get_channel

  queue = @queue_manager.get_queue(channel, queue)
  exchange = @queue_manager.get_exchange(channel, @event_raised_exchange)

  queue.unbind(exchange)
end