Class: ReliableMsg::MultiQueue
Overview
The MultiQueue
is a kind of clients. This offers two extentions to ReliableMsg::Queue
-
specify multiple target queues, by as comma-separated queue names.
-
specify prefix of a collection of queues by an asterisk at the end.
Exapmles:
-
"a.b.c"
targets single queue. -
"a.b.c, x.y.z"
targets two queues. -
"a.b.*"
targets a collection of queues such as “a.b.c”, “a.b.d”, etc. -
"a.b.*, x.y.*"
targets two collections.
Instance Method Summary collapse
-
#get(selector = nil, &block) ⇒ Object
Gets a message from target queues.
-
#initialize(multi_queue, options = nil) ⇒ MultiQueue
constructor
Creates a new
MultiQueue
with target queues specified bymulti_queue
. -
#name ⇒ Object
Returns multi queue expression as
String
.
Constructor Details
#initialize(multi_queue, options = nil) ⇒ MultiQueue
Creates a new MultiQueue
with target queues specified by multi_queue
. See ReliableMsg::Queue
for options
.
19 20 21 22 |
# File 'lib/ap4r/multi_queue.rb', line 19 def initialize multi_queue, = nil @multi_queue = multi_queue @options = end |
Instance Method Details
#get(selector = nil, &block) ⇒ Object
Gets a message from target queues. Internally, first search a queue with the most stale message, and get a message from the queue by ReliableMsg::Queue#get
27 28 29 30 31 32 33 34 |
# File 'lib/ap4r/multi_queue.rb', line 27 def get selector = nil, &block queue_name = repeated {|qm| qm.stale_queue @multi_queue } return nil unless queue_name queue = Queue.new queue_name, @options queue.get selector, &block end |
#name ⇒ Object
Returns multi queue expression as String
.
37 38 39 |
# File 'lib/ap4r/multi_queue.rb', line 37 def name @multi_queue end |