Class: Skein::Client::Publisher

Inherits:
Skein::Connected show all
Defined in:
lib/skein/client/publisher.rb

Instance Attribute Summary

Attributes inherited from Skein::Connected

#connection, #context, #ident

Instance Method Summary collapse

Methods inherited from Skein::Connected

#channel, #connect, #connection_shared?, #create_channel, #lock, #reconnect, #repeat_until_not_nil

Constructor Details

#initialize(exchange_name, type: nil, durable: nil, connection: nil, context: nil) ⇒ Publisher

Instance Methods =====================================================



4
5
6
7
8
# File 'lib/skein/client/publisher.rb', line 4

def initialize(exchange_name, type: nil, durable: nil, connection: nil, context: nil)
  super(connection: connection, context: context)

  @queue = self.channel.send(type || :topic, exchange_name, durable: durable)
end

Instance Method Details

#close(delete_queue: false) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/skein/client/publisher.rb', line 15

def close(delete_queue: false)
  if (delete_queue)
    @queue.delete
  end

  super()
end

#publish!(message, routing_key = nil) ⇒ Object Also known as: <<



10
11
12
# File 'lib/skein/client/publisher.rb', line 10

def publish!(message, routing_key = nil)
  @queue.publish(JSON.dump(message), routing_key: routing_key)
end