Class: RabbitmqClient::MessagePublisher
- Inherits:
-
Object
- Object
- RabbitmqClient::MessagePublisher
- Defined in:
- lib/rabbitmq_client/message_publisher.rb
Overview
ExchangeRegistry is a store for all managed exchanges and their details
Defined Under Namespace
Classes: ConfirmationFailed
Instance Method Summary collapse
-
#initialize(data, exchange, channel, options) ⇒ MessagePublisher
constructor
A new instance of MessagePublisher.
- #publish ⇒ Object
- #wait_for_confirms ⇒ Object
Constructor Details
#initialize(data, exchange, channel, options) ⇒ MessagePublisher
Returns a new instance of MessagePublisher.
15 16 17 18 19 20 21 |
# File 'lib/rabbitmq_client/message_publisher.rb', line 15 def initialize(data, exchange, channel, ) @data = data.to_json @exchange = exchange @channel = channel @options = { headers: {} }.merge() @options[:headers][:tags] = TagsFilter. end |
Instance Method Details
#publish ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/rabbitmq_client/message_publisher.rb', line 23 def publish exchange = @exchange.create(@channel) notify('publishing_message') exchange.publish(@data, **@options) notify('published_message') end |
#wait_for_confirms ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/rabbitmq_client/message_publisher.rb', line 31 def wait_for_confirms notify('confirming_message') if @channel.wait_for_confirms notify('message_confirmed') return end raise ConfirmationFailed.new(@exchange.name, @channel.nacked_set, @channel.unconfirmed_set) end |