Class: GorgService::Producer
- Inherits:
-
Object
- Object
- GorgService::Producer
- Defined in:
- lib/gorg_service/producer.rb
Instance Attribute Summary collapse
-
#default_exchange ⇒ Object
Returns the value of attribute default_exchange.
-
#environment ⇒ Object
Returns the value of attribute environment.
Instance Method Summary collapse
-
#initialize(environment_: GorgService.environment, default_exchange_: nil) ⇒ Producer
constructor
A new instance of Producer.
- #publish_message(message, exchange: default_exchange) ⇒ Object
Constructor Details
#initialize(environment_: GorgService.environment, default_exchange_: nil) ⇒ Producer
Returns a new instance of Producer.
11 12 13 14 |
# File 'lib/gorg_service/producer.rb', line 11 def initialize(environment_: GorgService.environment ,default_exchange_: nil) self.environment=environment_ self.default_exchange= default_exchange_ || environment.event_exchange end |
Instance Attribute Details
#default_exchange ⇒ Object
Returns the value of attribute default_exchange.
8 9 10 |
# File 'lib/gorg_service/producer.rb', line 8 def default_exchange @default_exchange end |
#environment ⇒ Object
Returns the value of attribute environment.
9 10 11 |
# File 'lib/gorg_service/producer.rb', line 9 def environment @environment end |
Instance Method Details
#publish_message(message, exchange: default_exchange) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/gorg_service/producer.rb', line 17 def (, exchange: default_exchange) x=exchange.is_a?(Bunny::Exchange) ? exchange : environment.find_exchange_by_name(exchange) GorgService.logger.info "Publish to #{x.name} - key : #{.routing_key}" GorgService.logger.debug "Message content : #{.body.to_s[0...10000]}" x.publish(.to_json, .properties) end |