Class: Jobi::Clients::Rabbitmq
- Inherits:
-
Object
- Object
- Jobi::Clients::Rabbitmq
- Defined in:
- lib/jobi/clients/rabbitmq.rb
Constant Summary collapse
- QUEUE_OPTIONS =
{ durable: :durable }.freeze
- MESSAGE_OPTIONS =
{ persist: :persistent }.freeze
Instance Method Summary collapse
- #channel ⇒ Object
- #default_exchange ⇒ Object
-
#initialize(config = Jobi::Config::Rabbitmq.new) ⇒ Rabbitmq
constructor
A new instance of Rabbitmq.
- #publish(message:, queue:, options: {}) ⇒ Object
- #queue(name:, options: {}) ⇒ Object
Constructor Details
Instance Method Details
#channel ⇒ Object
20 21 22 |
# File 'lib/jobi/clients/rabbitmq.rb', line 20 def channel @channel ||= @connection.create_channel end |
#default_exchange ⇒ Object
24 25 26 |
# File 'lib/jobi/clients/rabbitmq.rb', line 24 def default_exchange @default_exchange ||= channel.default_exchange end |
#publish(message:, queue:, options: {}) ⇒ Object
33 34 35 |
# File 'lib/jobi/clients/rabbitmq.rb', line 33 def publish(message:, queue:, options: {}) queue.publish(, (, MESSAGE_OPTIONS)) end |
#queue(name:, options: {}) ⇒ Object
28 29 30 31 |
# File 'lib/jobi/clients/rabbitmq.rb', line 28 def queue(name:, options: {}) default_exchange channel.queue(name, (, QUEUE_OPTIONS)) end |