Class: SmartQue::Publisher
- Inherits:
-
SmartQue::Publishers::Base
- Object
- SmartQue::Publishers::Base
- SmartQue::Publisher
- Defined in:
- lib/smart_que/publisher.rb
Instance Method Summary collapse
-
#initialize ⇒ Publisher
constructor
Initialize.
-
#publish(queue, options = {}) ⇒ Object
Publish message to the respective queue.
Methods inherited from SmartQue::Publishers::Base
#channel, #config, #connection, #get_queue, #log_message, #queue_list, #x_direct
Constructor Details
#initialize ⇒ Publisher
Initialize
7 8 9 10 11 12 |
# File 'lib/smart_que/publisher.rb', line 7 def initialize queue_list.each do |q_name| q = get_queue(q_name) q.bind(x_direct, routing_key: q.name) end end |
Instance Method Details
#publish(queue, options = {}) ⇒ Object
Publish message to the respective queue
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/smart_que/publisher.rb', line 17 def publish(queue, = {}) # Check queue name includes in the configured list # Return if queue doesn't exist if queue_list.include? queue # Publish sms to queue x_direct.publish( .to_json, mandatory: true, routing_key: get_queue(queue).name ) ("Publish status: success, Queue : #{queue}, Content : #{}") else ("Publish status: failed, Queue(#{queue}) doesn't exist.") ("Content : #{}") raise QueueNotFoundError end end |