Class: AMQP::Hermes::Transmitter
- Inherits:
-
Object
- Object
- AMQP::Hermes::Transmitter
- Includes:
- Connectivity
- Defined in:
- lib/amqp-hermes/transmitter.rb
Instance Attribute Summary collapse
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
Instance Method Summary collapse
- #close ⇒ Object
- #done_transmitting? ⇒ Boolean
-
#initialize(queue = nil, topic = nil, options = {}) ⇒ Transmitter
constructor
A new instance of Transmitter.
- #transmit(payload, options = {}) ⇒ Object
Methods included from Connectivity
#channel, #connection, #open?, #open_channel, #open_connection
Constructor Details
#initialize(queue = nil, topic = nil, options = {}) ⇒ Transmitter
Returns a new instance of Transmitter.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/amqp-hermes/transmitter.rb', line 7 def initialize(queue=nil, topic=nil, ={}) @queue = queue if topic.is_a?(Hash) = topic.clone topic = [:topic] end [:auto_delete] ||= true topic ||= "pub/sub" @exchange = channel.topic(topic, ) @transmitting = false end |
Instance Attribute Details
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
6 7 8 |
# File 'lib/amqp-hermes/transmitter.rb', line 6 def queue @queue end |
Instance Method Details
#close ⇒ Object
39 40 41 42 |
# File 'lib/amqp-hermes/transmitter.rb', line 39 def close AMQP::Hermes.wait_for(self, :done_transmitting?) super end |
#done_transmitting? ⇒ Boolean
35 36 37 |
# File 'lib/amqp-hermes/transmitter.rb', line 35 def done_transmitting? @transmitting == true ? false : true end |
#transmit(payload, options = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/amqp-hermes/transmitter.rb', line 23 def transmit(payload, ={}) @transmitting = true .merge!( :routing_key => @queue ) unless .has_key?(:routing_key) @exchange.publish( payload, ) do @transmitting = false end end |