amqp_notifier 0.0.4 → 0.0.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.
- data/Rakefile +1 -1
- data/amqp_notifier.gemspec +2 -2
- data/lib/amqp_notifier.rb +7 -5
- metadata +3 -3
data/Rakefile
CHANGED
data/amqp_notifier.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{amqp_notifier}
|
5
|
-
s.version = "0.0.
|
5
|
+
s.version = "0.0.5"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Pau"]
|
9
|
-
s.date = %q{2011-05-
|
9
|
+
s.date = %q{2011-05-06}
|
10
10
|
s.description = %q{AMQP & Qusion helper class}
|
11
11
|
s.email = %q{pau@nosolopau.com}
|
12
12
|
s.extra_rdoc_files = ["README.rdoc", "lib/amqp_notifier.rb"]
|
data/lib/amqp_notifier.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class AmqpNotifier
|
2
2
|
DEFAULT_EXCHANGE = 'labs_tests_1'
|
3
|
-
DEFAULT_OPTIONS = {:durable => true, :
|
3
|
+
DEFAULT_OPTIONS = {:durable => true, :type => :topic}
|
4
4
|
DEFAULT_PREFIX = ''
|
5
5
|
DEFAULT_QUEUE = 'default'
|
6
6
|
RETRIES = 10
|
@@ -13,12 +13,13 @@ class AmqpNotifier
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def publish(key = '', message = '')
|
16
|
-
|
17
|
-
|
16
|
+
$stderr.puts "#{key}:"
|
17
|
+
$stderr.puts "#{message}"
|
18
18
|
Qusion.channel.topic(@exchange, @options).publish(message, :key => @key_prefix + key)
|
19
19
|
end
|
20
20
|
|
21
21
|
def subscribe(key = '', &block)
|
22
|
+
$stdout.puts "Subscriction to Exchange: #{@exchange} Queue: #{@queue} Key: #{key}"
|
22
23
|
Qusion.channel.prefetch(1).queue(@queue, :durable => true).bind(Qusion.channel.topic(@exchange, @options), :key => key).subscribe(:ack => true) do |info, message|
|
23
24
|
for i in (0..RETRIES)
|
24
25
|
begin
|
@@ -26,8 +27,9 @@ class AmqpNotifier
|
|
26
27
|
info.ack
|
27
28
|
break
|
28
29
|
rescue => e
|
29
|
-
|
30
|
-
|
30
|
+
$stderr.puts "Error executing block amqp"
|
31
|
+
$stderr.puts "#{e.inspect}:"
|
32
|
+
e.backtrace.each {|line| $stderr.puts line}
|
31
33
|
if i == RETRIES
|
32
34
|
AmqpNotifier.new("#{@exchange}_errors").publish(key, message)
|
33
35
|
info.reject(:requeue => false)
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 5
|
9
|
+
version: 0.0.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Pau
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-05-
|
17
|
+
date: 2011-05-06 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|