Class: RabbitmqClient::Publisher
- Inherits:
-
Object
- Object
- RabbitmqClient::Publisher
- Defined in:
- lib/rabbitmq_client/publisher.rb
Overview
Publisher class is responsible for publishing events to rabbitmq exhanges
Instance Method Summary collapse
-
#initialize(**config) ⇒ Publisher
constructor
A new instance of Publisher.
- #publish(data, options) ⇒ Object
Constructor Details
#initialize(**config) ⇒ Publisher
Returns a new instance of Publisher.
8 9 10 11 12 13 14 15 |
# File 'lib/rabbitmq_client/publisher.rb', line 8 def initialize(**config) @config = config @session_params = session_params @exchange_registry = @config.fetch(:exchange_registry, nil) @session_params.freeze @session_pool = create_connection_pool notify('publisher_created', @session_params) end |
Instance Method Details
#publish(data, options) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rabbitmq_client/publisher.rb', line 17 def publish(data, ) return nil unless @exchange_registry if async PublisherJob.perform_async(@exchange_registry, @session_pool, data, ) else PublisherJob.new.perform(@exchange_registry, @session_pool, data, ) end end |