rservicebus2 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/return_messages_to_source_queue +99 -99
- data/lib/rservicebus/test.rb +0 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af6224237bfbbe009d831bb7b31479fdea298c2a
|
4
|
+
data.tar.gz: f51e1bcd024999a267dbecdafb39ecc13c41e22e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 239da2f85596cf0778b3c14dd555ba7e5827bab4f162242119d426aa664274cddf2894845acbe30c9910eab3442d236d32a34adf7d533bf1bec6cada55b695fb
|
7
|
+
data.tar.gz: d542ad8d463be94176ad3e776d23c5253e2cced5b9afd55f29be3557f7081f9edff6ce490f2ad4ad3c3557d9eded598160bf3cf47be93eeeb2853f8af21a3e46
|
@@ -4,111 +4,111 @@ require 'yaml'
|
|
4
4
|
require 'beanstalk-client'
|
5
5
|
require 'rservicebus'
|
6
6
|
|
7
|
-
def
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
puts '#' + "#{request_nbr.to_s}: #{msgName} to #{queueName}"
|
30
|
-
|
31
|
-
beanstalk.use( queueName )
|
32
|
-
beanstalk.put( payload )
|
33
|
-
|
34
|
-
job.delete
|
35
|
-
end
|
7
|
+
def return_msg(beanstalk, job, request_nbr)
|
8
|
+
first_match = 'ruby/object:'
|
9
|
+
payload = job.body
|
10
|
+
|
11
|
+
first_index = payload.index(first_match)
|
12
|
+
start_index = payload.index(first_match, first_index + 1) + first_match.length
|
13
|
+
|
14
|
+
msg_name = payload.match('(\w*)', start_index)[1]
|
15
|
+
|
16
|
+
msg = YAML.load(payload)
|
17
|
+
if msg.last_error_string.nil?
|
18
|
+
puts "*** Requested msg, #{request_nbr}, does not have a sourceQueue to
|
19
|
+
which it can be returned"
|
20
|
+
puts '*** Only errored msgs can be Returned'
|
21
|
+
puts '*** Generally, msgs would not be manually moved between queues'
|
22
|
+
puts '*** If you do need to, try'
|
23
|
+
puts '*** beanstalk-admin-dump <source queue name> | beanstalk-admin-load
|
24
|
+
<destination queue name>'
|
25
|
+
|
26
|
+
job.release
|
27
|
+
return
|
28
|
+
end
|
36
29
|
|
30
|
+
queue_name = msg.last_error_source_queue
|
31
|
+
puts '#' + "#{request_nbr}: #{msg_name} to #{queue_name}"
|
37
32
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
33
|
+
beanstalk.use(queue_name)
|
34
|
+
beanstalk.put(payload)
|
35
|
+
|
36
|
+
job.delete
|
37
|
+
end
|
38
|
+
|
39
|
+
index = nil
|
40
|
+
if ARGV.length == 0
|
41
|
+
queue_name = 'error'
|
42
|
+
elsif ARGV.length == 1
|
43
|
+
queue_name = ARGV[0]
|
44
|
+
elsif ARGV.length == 2
|
45
|
+
queue_name = ARGV[0]
|
46
|
+
index = ARGV[1].to_i
|
46
47
|
else
|
47
|
-
|
48
|
+
abort('Usage: ReturnMessagesToSourceQueue [queue name] [index]')
|
48
49
|
end
|
49
50
|
|
50
51
|
begin
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
52
|
+
host = 'localhost:11300'
|
53
|
+
beanstalk = Beanstalk::Pool.new([host])
|
54
|
+
|
55
|
+
tubes = beanstalk.list_tubes[host]
|
56
|
+
abort("Nothing waiting on the Beanstalk queue, #{queue_name}") unless
|
57
|
+
tubes.include?(queue_name)
|
58
|
+
|
59
|
+
tube_stats = beanstalk.stats_tube(queue_name)
|
60
|
+
number_of_messages = tube_stats['current-jobs-ready']
|
61
|
+
if index.nil?
|
62
|
+
puts
|
63
|
+
puts "Attempting to return #{number_of_messages} to their source queue"
|
64
|
+
puts
|
65
|
+
|
66
|
+
begin
|
67
|
+
beanstalk.watch(queue_name)
|
68
|
+
1.upto(number_of_messages) do |request_nbr|
|
69
|
+
job = beanstalk.reserve 1
|
70
|
+
|
71
|
+
return_msg( beanstalk, job, request_nbr )
|
72
|
+
end
|
73
|
+
rescue StandardError => e
|
74
|
+
if e.message == 'TIMED_OUT'
|
75
|
+
else
|
76
|
+
raise
|
77
|
+
end
|
57
78
|
end
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
begin
|
67
|
-
beanstalk.watch(queueName)
|
68
|
-
1.upto(number_of_messages) do |request_nbr|
|
69
|
-
job = beanstalk.reserve 1
|
70
|
-
|
71
|
-
returnMsg( beanstalk, job, request_nbr )
|
72
|
-
end
|
73
|
-
rescue Exception => e
|
74
|
-
if e.message == 'TIMED_OUT' then
|
75
|
-
else
|
76
|
-
raise
|
77
|
-
end
|
78
|
-
end
|
79
|
-
else
|
80
|
-
if index > number_of_messages then
|
81
|
-
puts "*** Requested msg, #{index}, is greater than the number of msgs in the queue, #{number_of_messages}"
|
82
|
-
puts '*** Try a smaller index, or remove the index number to return all msgs'
|
83
|
-
abort();
|
84
|
-
end
|
85
|
-
|
86
|
-
puts
|
87
|
-
puts "Attempting to msg number, #{index} to it's source queue"
|
88
|
-
puts
|
89
|
-
|
90
|
-
begin
|
91
|
-
beanstalk.watch(queueName)
|
92
|
-
jobList = Array.new
|
93
|
-
1.upto(index-1) do |request_nbr|
|
94
|
-
job = beanstalk.reserve 1
|
95
|
-
jobList << job
|
96
|
-
end
|
97
|
-
job = beanstalk.reserve 1
|
98
|
-
returnMsg( beanstalk, job, index )
|
99
|
-
|
100
|
-
jobList.each do |job|
|
101
|
-
job.release
|
102
|
-
end
|
103
|
-
|
104
|
-
rescue Exception => e
|
105
|
-
if e.message == 'TIMED_OUT' then
|
106
|
-
else
|
107
|
-
raise
|
108
|
-
end
|
109
|
-
end
|
79
|
+
else
|
80
|
+
if index > number_of_messages
|
81
|
+
puts "*** Requested msg, #{index}, is greater than the number of msgs in
|
82
|
+
the queue, #{number_of_messages}"
|
83
|
+
puts '*** Try a smaller index, or remove the index number to return all
|
84
|
+
msgs'
|
85
|
+
abort
|
110
86
|
end
|
111
|
-
|
112
|
-
|
87
|
+
|
88
|
+
puts
|
89
|
+
puts "Attempting to msg number, #{index} to it's source queue"
|
90
|
+
puts
|
91
|
+
|
92
|
+
begin
|
93
|
+
beanstalk.watch(queue_name)
|
94
|
+
job_list = []
|
95
|
+
1.upto(index-1) do |request_nbr|
|
96
|
+
job = beanstalk.reserve 1
|
97
|
+
job_list << job
|
98
|
+
end
|
99
|
+
job = beanstalk.reserve 1
|
100
|
+
return_msg(beanstalk, job, index)
|
101
|
+
|
102
|
+
job_list.each(&:release)
|
103
|
+
|
104
|
+
rescue StandardError => e
|
105
|
+
if e.message == 'TIMED_OUT'
|
106
|
+
else
|
107
|
+
raise
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
rescue Beanstalk::NotConnected
|
113
113
|
puts 'Beanstalk not running'
|
114
|
-
end
|
114
|
+
end
|
data/lib/rservicebus/test.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rservicebus2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guy Irvine
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: uuidtools
|