ruby_q 1.1.4 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/message_queue_router.rb +23 -13
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cca25551ad4eadd50c466bd72c5d4c70562e6399
|
4
|
+
data.tar.gz: 23904d6d139689befddc9712f6587f76c5de9b79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa2f2498223e6403a8a7b7cab634097a2284857f9d40c66ba031980121e94c5a28ed0a64432e0ba785288ae0e9ff73a4e550e369a121ad417c35c324c30dffaa
|
7
|
+
data.tar.gz: 9fbfd50a03f005ca79e98b41a9f9c311b57babb53961ef5356824cea104fc046469ff7275f0b681be4debac521b66e65bdf1d0476982ac05c234f1d7c310605d
|
data/lib/message_queue_router.rb
CHANGED
@@ -15,24 +15,34 @@ class Message_queue_router
|
|
15
15
|
#target_queue = queue_exists?(name)
|
16
16
|
|
17
17
|
if queue_exists?(name)
|
18
|
-
|
19
|
-
while mq.in_use?
|
20
|
-
sleep 0.5
|
21
|
-
end
|
22
|
-
mq.lock
|
23
|
-
ret = mq.parse_command(command, client)
|
24
|
-
mq.unlock
|
25
|
-
else
|
26
|
-
puts Time.now.getutc.to_s + " - Queue not found, creating queue " + name
|
27
|
-
new_queue = MQStruct.new(name)
|
28
|
-
ret = new_queue.parse_command(command, client)
|
29
|
-
mq_list << new_queue
|
18
|
+
create_queue(name)
|
30
19
|
end
|
20
|
+
|
21
|
+
ret = use_queue(name, command, client)
|
22
|
+
|
23
|
+
return ret
|
24
|
+
end
|
25
|
+
|
26
|
+
def create_queue(name)
|
27
|
+
puts Time.now.getutc.to_s + " - Queue not found, creating queue " + name
|
28
|
+
new_queue = MQStruct.new(name)
|
29
|
+
@mq_list << new_queue
|
30
|
+
end
|
31
|
+
|
32
|
+
def use_queue(name, command, client)
|
33
|
+
mq = @mq_list.select { |q| q.name == name }[0]
|
34
|
+
while mq.in_use?
|
35
|
+
sleep 0.5
|
36
|
+
end
|
37
|
+
mq.lock
|
38
|
+
ret = mq.parse_command(command, client)
|
39
|
+
mq.unlock
|
40
|
+
|
31
41
|
return ret
|
32
42
|
end
|
33
43
|
|
34
44
|
def queue_exists?(name)
|
35
|
-
mq_list.each { |q|
|
45
|
+
@mq_list.each { |q|
|
36
46
|
if q.name == name
|
37
47
|
return q
|
38
48
|
end
|