Module: Twingly::AMQP::Publisher
- Included in:
- DefaultExchangePublisher, TopicExchangePublisher
- Defined in:
- lib/twingly/amqp/publisher.rb
Instance Method Summary collapse
- #configure_publish_options {|options| ... } ⇒ Object
- #publish(message, opts = {}) ⇒ Object
-
#publish_with_confirm(message, opts = {}) ⇒ Object
Only used by tests to lessen the time we need to sleep.
Instance Method Details
#configure_publish_options {|options| ... } ⇒ Object
29 30 31 |
# File 'lib/twingly/amqp/publisher.rb', line 29 def yield end |
#publish(message, opts = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/twingly/amqp/publisher.rb', line 4 def publish(, opts = {}) payload = if .kind_of?(Array) elsif .respond_to?(:to_h) .to_h else raise ArgumentError end json_payload = payload.to_json = .to_h.merge(opts) @exchange.publish(json_payload, ) end |
#publish_with_confirm(message, opts = {}) ⇒ Object
Only used by tests to lessen the time we need to sleep
20 21 22 23 24 25 26 27 |
# File 'lib/twingly/amqp/publisher.rb', line 20 def publish_with_confirm(, opts = {}) channel = @exchange.channel channel.confirm_select unless channel.using_publisher_confirmations? publish(, opts) @exchange.wait_for_confirms end |