amqp-boilerplate 1.1.0 → 1.1.1

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/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ = version 1.1.1
2
+
3
+ * [ENHANCEMENT] Pass additional parameters to on_unhandled_consumer_exception
4
+ handler
5
+
1
6
  = version 1.1.0
2
7
 
3
8
  * [FEATURE] Added on_unhandled_consumer_exception option to allow for more
data/README.rdoc CHANGED
@@ -21,7 +21,9 @@ Add a initializer +amqp.rb+ to your config/initializer folder with the following
21
21
  config.logger = ::Rails.logger
22
22
  config.consumer_paths += %W( #{Rails.root}/app/consumers )
23
23
  config.connection_options = { :host => "localhost", :port => 5672, :vhost => Rails.env }
24
- config.on_unhandled_exception = Proc.new { |exception| puts "Do something with exceptions: #{exception}" }
24
+ config.on_unhandled_exception = Proc.new { |exception, consumer, metadata, payload|
25
+ puts "Do something with exceptions: #{exception}"
26
+ }
25
27
  end
26
28
 
27
29
  # Require all files that are no longer auto-loaded when Rails is in thread-safe mode
@@ -61,7 +61,7 @@ module AMQP
61
61
  # config.logger = ::Rails.logger
62
62
  # config.consumer_paths += %W( #{Rails.root}/app/consumers )
63
63
  # config.connection_options = { :host => "localhost", :port => 5672, :vhost => Rails.env }
64
- # config.on_unhandled_exception = Proc.new { |exception| puts "Do something with exceptions: #{exception}" }
64
+ # config.on_unhandled_exception = Proc.new { |exception, consumer, metadata, payload| puts "Do something with exceptions: #{exception}" }
65
65
  # end
66
66
  def self.configure
67
67
  yield self if block_given?
@@ -90,7 +90,7 @@ module AMQP
90
90
  handle_message(metadata, payload)
91
91
  rescue Exception => e
92
92
  if AMQP::Boilerplate.on_unhandled_consumer_exception.is_a?(Proc)
93
- AMQP::Boilerplate.on_unhandled_consumer_exception.call(e)
93
+ AMQP::Boilerplate.on_unhandled_consumer_exception.call(e, self, metadata, payload)
94
94
  else
95
95
  raise e
96
96
  end
@@ -1,5 +1,5 @@
1
1
  module AMQP
2
2
  module Boilerplate
3
- VERSION = "1.1.0"
3
+ VERSION = "1.1.1"
4
4
  end
5
5
  end
@@ -132,6 +132,8 @@ describe AMQP::Boilerplate::Consumer do
132
132
  end
133
133
 
134
134
  describe "#handle_message_wrapper" do
135
+ subject { @consumer.handle_message_wrapper(@metadata, @payload) }
136
+
135
137
  before(:each) do
136
138
  @consumer = BarConsumer.new
137
139
 
@@ -141,25 +143,32 @@ describe AMQP::Boilerplate::Consumer do
141
143
 
142
144
  it "should let handle_message do the heavy lifting" do
143
145
  @consumer.should_receive(:handle_message).with(@metadata, @payload)
144
- @consumer.handle_message_wrapper(@metadata, @payload)
146
+ subject
145
147
  end
146
148
 
147
149
  context "when on_unhandled_consumer_exception option set" do
148
- before do
149
- AMQP::Boilerplate.stub(:on_unhandled_consumer_exception).and_return(Proc.new { |e|
150
+ let(:handler) do
151
+ Proc.new { |e,c,m,p|
150
152
  AMQP::Boilerplate.logger.error("foo: #{e.message}")
151
- })
153
+ }
154
+ end
155
+
156
+ before do
157
+ AMQP::Boilerplate.stub(:on_unhandled_consumer_exception).and_return(handler)
152
158
  end
153
159
 
154
160
  it "should not raise the exception" do
155
- expect {
156
- @consumer.handle_message_wrapper(@metadata, @payload)
157
- }.to_not raise_error
161
+ expect { subject }.to_not raise_error
158
162
  end
159
163
 
160
- it "should yield the on_unhandled_consumer_exception" do
164
+ it "should execute the on_unhandled_consumer_exception proc" do
161
165
  AMQP::Boilerplate.logger.should_receive(:error)
162
- @consumer.handle_message_wrapper(@metadata, @payload)
166
+ subject
167
+ end
168
+
169
+ it "should call the on_unhandled_consumer_exception proc with parameters" do
170
+ handler.should_receive(:call).with(NoMethodError, subject, @metadata, @payload)
171
+ subject
163
172
  end
164
173
  end
165
174
 
@@ -169,9 +178,7 @@ describe AMQP::Boilerplate::Consumer do
169
178
  end
170
179
 
171
180
  it "should re-raise the exception" do
172
- expect {
173
- @consumer.handle_message_wrapper(@metadata, @payload)
174
- }.to raise_error
181
+ expect { subject }.to raise_error
175
182
  end
176
183
  end
177
184
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amqp-boilerplate
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 0
10
- version: 1.1.0
9
+ - 1
10
+ version: 1.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Patrick Baselier