rservicebus 0.0.25 → 0.0.26
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.
@@ -6,39 +6,44 @@ require "beanstalk-client"
|
|
6
6
|
|
7
7
|
require "rservicebus"
|
8
8
|
|
9
|
-
host = 'localhost:11300'
|
10
|
-
errorQueueName = "error"
|
11
|
-
beanstalk = Beanstalk::Pool.new([host])
|
12
|
-
|
13
|
-
tubes = beanstalk.list_tubes[host]
|
14
|
-
if !tubes.include?(errorQueueName) then
|
15
|
-
abort( "Nothing waiting on the error queue" )
|
16
|
-
end
|
17
|
-
|
18
|
-
tubeStats = beanstalk.stats_tube(errorQueueName)
|
19
|
-
number_of_messages = tubeStats["current-jobs-ready"]
|
20
|
-
puts
|
21
|
-
puts "Attempting to return #{number_of_messages} to their source queue"
|
22
|
-
puts
|
23
|
-
|
24
9
|
begin
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
10
|
+
host = 'localhost:11300'
|
11
|
+
errorQueueName = "error"
|
12
|
+
beanstalk = Beanstalk::Pool.new([host])
|
13
|
+
|
14
|
+
tubes = beanstalk.list_tubes[host]
|
15
|
+
if !tubes.include?(errorQueueName) then
|
16
|
+
abort( "Nothing waiting on the Beanstalk error queue" )
|
17
|
+
end
|
18
|
+
|
19
|
+
tubeStats = beanstalk.stats_tube(errorQueueName)
|
20
|
+
number_of_messages = tubeStats["current-jobs-ready"]
|
21
|
+
puts
|
22
|
+
puts "Attempting to return #{number_of_messages} to their source queue"
|
23
|
+
puts
|
24
|
+
|
25
|
+
begin
|
26
|
+
beanstalk.watch(errorQueueName)
|
27
|
+
1.upto(number_of_messages) do |request_nbr|
|
28
|
+
job = beanstalk.reserve 1
|
29
|
+
payload = job.body
|
30
|
+
|
31
|
+
puts "#" + request_nbr.to_s + ": " + payload
|
32
|
+
msg = YAML::load(payload)
|
33
|
+
queueName = msg.getLastErrorMsg.sourceQueue
|
34
|
+
|
35
|
+
beanstalk.use( queueName )
|
36
|
+
beanstalk.put( payload )
|
37
|
+
|
38
|
+
job.delete
|
39
|
+
end
|
40
|
+
rescue Exception => e
|
41
|
+
if e.message == "TIMED_OUT" then
|
42
|
+
else
|
43
|
+
raise
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
rescue Beanstalk::NotConnected=>e
|
48
|
+
puts "Beanstalk not running"
|
44
49
|
end
|
@@ -6,41 +6,46 @@ require "bunny"
|
|
6
6
|
|
7
7
|
require "rservicebus"
|
8
8
|
|
9
|
-
host = 'localhost
|
9
|
+
host = 'localhost'
|
10
|
+
port = '5672'
|
10
11
|
errorQueueName = "error"
|
11
12
|
|
12
|
-
|
13
|
-
bunny.
|
14
|
-
|
15
|
-
|
16
|
-
q = @bunny.queue(errorQueueName)
|
17
|
-
|
18
|
-
number_of_messages = 0
|
19
|
-
loop = true
|
20
|
-
while loop do
|
21
|
-
msg = q.pop[:payload]
|
22
|
-
if msg == :queue_empty then
|
23
|
-
loop = false
|
24
|
-
else
|
25
|
-
number_of_messages++
|
26
|
-
|
27
|
-
msg = YAML::load(msg)
|
28
|
-
|
29
|
-
queueName = msg.getLastErrorMsg.sourceQueue
|
30
|
-
sq = bunny.queue(queueName)
|
31
|
-
sq.bind(@direct_exchange)
|
32
|
-
#q.publish( serialized_object )
|
33
|
-
|
34
|
-
@direct_exchange.publish(msg)
|
35
|
-
end
|
36
|
-
end
|
13
|
+
begin
|
14
|
+
bunny = Bunny.new(:host=>host, :port=>port)
|
15
|
+
bunny.start
|
16
|
+
direct_exchange = bunny.exchange('rservicebus.agent')
|
37
17
|
|
18
|
+
q = bunny.queue(errorQueueName)
|
38
19
|
|
39
|
-
|
40
|
-
|
41
|
-
|
20
|
+
number_of_messages = 0
|
21
|
+
loop = true
|
22
|
+
while loop do
|
23
|
+
msg = q.pop[:payload]
|
24
|
+
if msg == :queue_empty then
|
25
|
+
loop = false
|
26
|
+
else
|
27
|
+
number_of_messages++
|
28
|
+
|
29
|
+
msg = YAML::load(msg)
|
30
|
+
|
31
|
+
queueName = msg.getLastErrorMsg.sourceQueue
|
32
|
+
sq = bunny.queue(queueName)
|
33
|
+
sq.bind(@direct_exchange)
|
34
|
+
#q.publish( serialized_object )
|
35
|
+
|
36
|
+
@direct_exchange.publish(msg)
|
37
|
+
end
|
38
|
+
end
|
42
39
|
|
43
|
-
puts "Returned #{number_of_messages} to their source queue"
|
44
40
|
|
41
|
+
if number_of_messages == 0 then
|
42
|
+
puts "Nothing waiting on RabbitMq error queue"
|
43
|
+
else
|
44
|
+
|
45
|
+
puts "Returned #{number_of_messages} to their source queue"
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
rescue Bunny::ConnectionError, Bunny::ServerDownError => e
|
50
|
+
abort( "RabbitMq not running" )
|
45
51
|
end
|
46
|
-
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rservicebus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.26
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -15,6 +15,7 @@ description: A Ruby interpretation of NServiceBus
|
|
15
15
|
email: guy@guyirvine.com
|
16
16
|
executables:
|
17
17
|
- rservicebus
|
18
|
+
- ReturnErroredMessagesToSourceQueue
|
18
19
|
- ReturnErroredMessagesToSourceQueueBeanstalk
|
19
20
|
- ReturnErroredMessagesToSourceQueueBunny
|
20
21
|
extensions: []
|
@@ -52,6 +53,7 @@ files:
|
|
52
53
|
- lib/rservicebus/Test/Redis.rb
|
53
54
|
- lib/rservicebus/Test.rb
|
54
55
|
- lib/rservicebus.rb
|
56
|
+
- bin/ReturnErroredMessagesToSourceQueue
|
55
57
|
- bin/ReturnErroredMessagesToSourceQueueBeanstalk
|
56
58
|
- bin/ReturnErroredMessagesToSourceQueueBunny
|
57
59
|
- bin/rservicebus
|