Module: RuoteAMQP
- Defined in:
- lib/ruote-amqp.rb,
lib/ruote-amqp/version.rb,
lib/ruote-amqp/receiver.rb,
lib/ruote-amqp/participant.rb,
lib/ruote-amqp/workitem_listener.rb,
lib/ruote-amqp/launchitem_listener.rb
Overview
AMQP participant and listener pair for ruote.
Documentation
See #RuoteAMQP::Listener and #RuoteAMQP::Participant for detailed documentation on using each of them.
AMQP Notes
RuoteAMQP uses durable queues and persistent messages by default, to ensure no messages get lost along the way and that running expressions doesn’t have to be restarted in order for messages to be resent.
Defined Under Namespace
Classes: LaunchitemListener, Participant, ParticipantProxy, Receiver, WorkitemListener
Constant Summary collapse
- VERSION =
'2.2.0'
Class Attribute Summary collapse
-
.use_persistent_messages ⇒ Object
writeonly
Sets the attribute use_persistent_messages.
Class Method Summary collapse
-
.start! ⇒ Object
Ensure the AMQP connection is started.
-
.started! ⇒ Object
:nodoc:.
-
.started? ⇒ Boolean
Check whether the AMQP connection is started.
-
.stop! ⇒ Object
Close down the AMQP connections.
-
.use_persistent_messages? ⇒ Boolean
Whether or not to use persistent messages (true by default).
Class Attribute Details
.use_persistent_messages=(value) ⇒ Object (writeonly)
Sets the attribute use_persistent_messages
31 32 33 |
# File 'lib/ruote-amqp.rb', line 31 def (value) @use_persistent_messages = value end |
Class Method Details
.start! ⇒ Object
Ensure the AMQP connection is started
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/ruote-amqp.rb', line 40 def start! return if started? mutex = Mutex.new cv = ConditionVariable.new Thread.main[:ruote_amqp_connection] = Thread.new do Thread.abort_on_exception = true AMQP.start { started! cv.signal } end mutex.synchronize { cv.wait(mutex) } MQ.prefetch(1) yield if block_given? end |
.started! ⇒ Object
:nodoc:
66 67 68 |
# File 'lib/ruote-amqp.rb', line 66 def started! #:nodoc: Thread.main[:ruote_amqp_started] = true end |
.started? ⇒ Boolean
Check whether the AMQP connection is started
62 63 64 |
# File 'lib/ruote-amqp.rb', line 62 def started? Thread.main[:ruote_amqp_started] == true end |
.stop! ⇒ Object
Close down the AMQP connections
71 72 73 74 75 76 77 |
# File 'lib/ruote-amqp.rb', line 71 def stop! return unless started? AMQP.stop Thread.main[:ruote_amqp_connection].join Thread.main[:ruote_amqp_started] = false end |
.use_persistent_messages? ⇒ Boolean
Whether or not to use persistent messages (true by default)
34 35 36 37 |
# File 'lib/ruote-amqp.rb', line 34 def @use_persistent_messages = true if @use_persistent_messages.nil? @use_persistent_messages end |