euston-rabbitmq 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/Rakefile +0 -21
- data/euston-rabbitmq.gemspec +26 -37
- data/lib/euston-rabbitmq/{bindings → euston}/command_handler_binder.rb +2 -2
- data/lib/euston-rabbitmq/{errors.rb → euston/errors.rb} +1 -1
- data/lib/euston-rabbitmq/{bindings → euston}/event_handler_binder.rb +4 -4
- data/lib/euston-rabbitmq/{exchanges.rb → euston/exchanges.rb} +1 -1
- data/lib/euston-rabbitmq/{bindings → euston}/handler_binder.rb +2 -1
- data/lib/euston-rabbitmq/{queues.rb → euston/queues.rb} +1 -1
- data/lib/euston-rabbitmq/{subscriptions/retriable_subscription.rb → euston/retrying_subscription.rb} +17 -16
- data/lib/euston-rabbitmq/rabbitmq_client/queue.rb +70 -0
- data/lib/euston-rabbitmq/rabbitmq_client/reactive_message.rb +15 -0
- data/lib/euston-rabbitmq/{constant_loader.rb → reflection/constant_loader.rb} +0 -0
- data/lib/euston-rabbitmq/{handler_finder.rb → reflection/handler_finder.rb} +0 -0
- data/lib/euston-rabbitmq/{handler_reference.rb → reflection/handler_reference.rb} +0 -0
- data/lib/euston-rabbitmq/version.rb +1 -1
- data/lib/euston-rabbitmq.rb +8 -22
- data/spec/euston/command_handler_binder_spec.rb +24 -0
- data/spec/euston/event_handler_binder_spec.rb +36 -0
- data/spec/euston/exchanges_spec.rb +27 -0
- data/spec/euston/queues_spec.rb +24 -0
- data/spec/euston/retrying_subscription_spec.rb +74 -0
- data/spec/rabbitmq_client/queue_spec.rb +69 -0
- data/spec/{constant_loader_spec.rb → reflection/constant_loader_spec.rb} +3 -1
- data/spec/{handler_finder_spec.rb → reflection/handler_finder_spec.rb} +3 -1
- data/spec/spec_helper.rb +19 -52
- data/spec/support/filters.rb +10 -0
- data/spec/support/queue_subscription_thread_harness.rb +29 -0
- data/spec/support/rabbitmqadmin.rb +74 -0
- metadata +58 -117
- data/lib/euston-rabbitmq/command_handlers/retry_failed_message.rb +0 -29
- data/lib/euston-rabbitmq/event_handlers/message_failure.rb +0 -27
- data/lib/euston-rabbitmq/message_buffer.rb +0 -67
- data/lib/euston-rabbitmq/message_logger.rb +0 -50
- data/lib/euston-rabbitmq/queue.rb +0 -30
- data/lib/euston-rabbitmq/read_model/failed_message.rb +0 -36
- data/lib/euston-rabbitmq/read_model/message_buffer.rb +0 -57
- data/lib/euston-rabbitmq/read_model/message_log.rb +0 -37
- data/spec/command_buffer_spec.rb +0 -69
- data/spec/event_buffer_spec.rb +0 -69
- data/spec/exchange_declaration_spec.rb +0 -28
- data/spec/message_failure_spec.rb +0 -77
- data/spec/mt_safe_queue_subscription_spec.rb +0 -72
- data/spec/safe_queue_subscription_spec.rb +0 -50
- data/spec/support/factories.rb +0 -18
@@ -1,50 +0,0 @@
|
|
1
|
-
require File.expand_path('../spec_helper.rb', __FILE__)
|
2
|
-
|
3
|
-
unless RUBY_PLATFORM == 'java'
|
4
|
-
describe 'message-failure-aware queue subscription' do
|
5
|
-
include EustonRmqSpec
|
6
|
-
|
7
|
-
PUBLISH_OPTS = { :immediate => false,
|
8
|
-
:mandatory => true,
|
9
|
-
:persistent => true,
|
10
|
-
:routing_key => 'messages.xyz' }
|
11
|
-
|
12
|
-
amqp_before do
|
13
|
-
@exchange = @channel.topic "test-#{Euston.uuid.generate}", :durable => true, :nowait => false
|
14
|
-
@queue = @channel.queue "test-#{Euston.uuid.generate}", :durable => true, :nowait => false
|
15
|
-
@queue.bind @exchange, :routing_key => 'messages.#'
|
16
|
-
@queue.safe_subscribe
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'adds a failure-aware subscription function to the amqp queue object' do
|
20
|
-
@queue.should respond_to(:safe_subscribe)
|
21
|
-
|
22
|
-
done 1
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'publishes the message-decode-failed event when a non-json message is received by the queue' do
|
26
|
-
count = 0
|
27
|
-
@queue.when :message_decode_failed => ->(message, error) { count = count + 1 }
|
28
|
-
|
29
|
-
delayed(0.3) { @exchange.publish ' *897d- -', PUBLISH_OPTS }
|
30
|
-
done(1) { count.should == 1 }
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'publishes the message-received event when a message is received by the queue' do
|
34
|
-
count = 0
|
35
|
-
@queue.when :message_received => ->(message) { count = count + 1 }
|
36
|
-
|
37
|
-
delayed(0.3) { @exchange.publish ::ActiveSupport::JSON.encode({ :a => :b }), PUBLISH_OPTS }
|
38
|
-
done(1) { count.should == 1 }
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'publishes the message-failed event when an exception occurs during the message-received handler' do
|
42
|
-
count = 0
|
43
|
-
@queue.when(:message_failed => ->(message, error, header) { count = count + 1 },
|
44
|
-
:message_received => ->(message) { raise 'Something bad happened' })
|
45
|
-
|
46
|
-
delayed(0.3) { @exchange.publish ::ActiveSupport::JSON.encode({ :a => :b }), PUBLISH_OPTS }
|
47
|
-
done(1) { count.should == 1 }
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
data/spec/support/factories.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
module Factory
|
2
|
-
class << self
|
3
|
-
def command_headers
|
4
|
-
{
|
5
|
-
:id => Euston.uuid.generate,
|
6
|
-
:type => Faker::Lorem.words(2).join('_'),
|
7
|
-
:version => 1
|
8
|
-
}
|
9
|
-
end
|
10
|
-
|
11
|
-
def command
|
12
|
-
{
|
13
|
-
:headers => Factory.command_headers,
|
14
|
-
:body => Hash[Faker::Lorem.words(3).map { |w| [w.downcase.to_sym, Faker::Lorem.words(3).join(' ')] }]
|
15
|
-
}
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|