euston-rabbitmq 1.1.0-java → 1.2.0-java
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -1
- data/euston-rabbitmq.gemspec +6 -6
- data/lib/euston-rabbitmq/euston/command_handler_binder.rb +17 -7
- data/lib/euston-rabbitmq/euston/event_handler_binder.rb +3 -3
- data/lib/euston-rabbitmq/euston/exchanges.rb +1 -1
- data/lib/euston-rabbitmq/euston/handler_binder.rb +4 -10
- data/lib/euston-rabbitmq/euston/retrying_subscription.rb +20 -13
- data/lib/euston-rabbitmq/{rabbitmq_client → hot_bunnies}/queue.rb +26 -18
- data/lib/euston-rabbitmq/hot_bunnies/reactive_message.rb +26 -0
- data/lib/euston-rabbitmq/reflection/handler_finder.rb +4 -3
- data/lib/euston-rabbitmq/version.rb +1 -1
- data/lib/euston-rabbitmq.rb +3 -3
- data/spec/euston/command_handler_binder_spec.rb +2 -2
- data/spec/euston/event_handler_binder_spec.rb +2 -2
- data/spec/euston/exchanges_spec.rb +0 -10
- data/spec/euston/queues_spec.rb +0 -9
- data/spec/euston/retrying_subscription_spec.rb +4 -3
- data/spec/rabbitmq_client/queue_spec.rb +1 -1
- data/spec/spec_helper.rb +20 -8
- data/spec/support/filters.rb +3 -8
- metadata +32 -32
- data/lib/euston-rabbitmq/rabbitmq_client/reactive_message.rb +0 -15
data/Gemfile
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
source :rubygems
|
2
2
|
gemspec
|
3
3
|
|
4
|
-
gem '
|
4
|
+
gem 'hot_bunnies', :git => 'https://github.com/ruby-amqp/hot_bunnies.git'
|
5
|
+
gem 'safely', :git => 'https://github.com/leemhenson/safely.git', :branch => 'override_strategies'
|
data/euston-rabbitmq.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'euston-rabbitmq'
|
3
|
-
s.version = '1.
|
3
|
+
s.version = '1.2.0'
|
4
4
|
s.platform = RUBY_PLATFORM.to_s == 'java' ? 'java' : Gem::Platform::RUBY
|
5
5
|
s.authors = ['Lee Henson', 'Guy Boertje']
|
6
6
|
s.email = ['lee.m.henson@gmail.com', 'guyboertje@gmail.com']
|
@@ -21,8 +21,8 @@ Gem::Specification.new do |s|
|
|
21
21
|
lib/euston-rabbitmq/euston/handler_binder.rb
|
22
22
|
lib/euston-rabbitmq/euston/queues.rb
|
23
23
|
lib/euston-rabbitmq/euston/retrying_subscription.rb
|
24
|
-
lib/euston-rabbitmq/
|
25
|
-
lib/euston-rabbitmq/
|
24
|
+
lib/euston-rabbitmq/hot_bunnies/queue.rb
|
25
|
+
lib/euston-rabbitmq/hot_bunnies/reactive_message.rb
|
26
26
|
lib/euston-rabbitmq/reflection/constant_loader.rb
|
27
27
|
lib/euston-rabbitmq/reflection/handler_finder.rb
|
28
28
|
lib/euston-rabbitmq/reflection/handler_reference.rb
|
@@ -45,12 +45,12 @@ Gem::Specification.new do |s|
|
|
45
45
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
46
46
|
|
47
47
|
s.add_dependency 'activesupport', '~> 3.0.10'
|
48
|
-
s.add_dependency 'euston', '~> 1.
|
49
|
-
s.add_dependency 'euston-eventstore', '~> 1.
|
48
|
+
s.add_dependency 'euston', '~> 1.2.0'
|
49
|
+
s.add_dependency 'euston-eventstore', '~> 1.2.0'
|
50
50
|
s.add_dependency 'hash-keys', '~> 1.0.0'
|
51
51
|
s.add_dependency 'hollywood', '~> 1.0.0'
|
52
52
|
s.add_dependency 'i18n', '~> 0.5.0'
|
53
|
-
s.add_dependency '
|
53
|
+
s.add_dependency 'hot_bunnies', '~> 1.3.0.pre1' if RUBY_PLATFORM.to_s == 'java'
|
54
54
|
s.add_dependency 'safely', '~> 0.3.0'
|
55
55
|
|
56
56
|
s.add_development_dependency 'awesome_print', '~> 0.4.0'
|
@@ -1,23 +1,33 @@
|
|
1
1
|
module Euston
|
2
2
|
module RabbitMq
|
3
3
|
class CommandHandlerBinder < HandlerBinder
|
4
|
+
include AggregateRootPrivateMethodNames
|
5
|
+
|
4
6
|
private
|
5
7
|
|
6
|
-
def ensure_bindings_exist_for_reference
|
8
|
+
def ensure_bindings_exist_for_reference reference
|
7
9
|
queue_name = :command_handlers
|
8
|
-
queue = get_command_handler_queue channel, queue_name
|
10
|
+
queue = get_command_handler_queue @channel, queue_name
|
11
|
+
|
12
|
+
if reference.handler.included_modules.include? AggregateRoot
|
13
|
+
routing_keys = reference.handler.instance_methods.map { |m| self.class.consumes_regex.match m }.compact.map { |m| m[1] }
|
14
|
+
else
|
15
|
+
routing_keys = ["#{reference.name.to_s.underscore}"]
|
16
|
+
end
|
9
17
|
|
10
|
-
|
18
|
+
exchange = get_exchange @channel, :commands
|
11
19
|
|
12
|
-
|
20
|
+
routing_keys.each do |routing_key|
|
21
|
+
routing_key = "commands.#{routing_key}"
|
13
22
|
|
14
|
-
|
15
|
-
|
23
|
+
@log.debug "Ensuring routing key exists for queue #{queue_name}: #{routing_key}"
|
24
|
+
queue.bind exchange, :routing_key => routing_key
|
25
|
+
end
|
16
26
|
end
|
17
27
|
|
18
28
|
def get_command_handler_queue channel, queue_name
|
19
29
|
@log.debug "Ensuring command handler queue exists: #{queue_name}" if @command_handler_queue.nil?
|
20
|
-
@command_handler_queue ||= get_queue channel, queue_name
|
30
|
+
@command_handler_queue ||= get_queue @channel, queue_name
|
21
31
|
end
|
22
32
|
end
|
23
33
|
end
|
@@ -3,12 +3,12 @@ module Euston
|
|
3
3
|
class EventHandlerBinder < HandlerBinder
|
4
4
|
private
|
5
5
|
|
6
|
-
def ensure_bindings_exist_for_reference
|
6
|
+
def ensure_bindings_exist_for_reference reference
|
7
7
|
queue_name = reference.name.to_s.underscore
|
8
8
|
|
9
9
|
@log.debug "Ensuring event handler queue exists: #{queue_name}"
|
10
10
|
|
11
|
-
queue = get_queue channel, queue_name
|
11
|
+
queue = get_queue @channel, queue_name
|
12
12
|
|
13
13
|
prefix = '__event_handler__'
|
14
14
|
|
@@ -17,7 +17,7 @@ module Euston
|
|
17
17
|
methods = methods.map { |method| method.to_s[prefix.length, method.to_s.length - prefix.length] }
|
18
18
|
methods = methods.map { |method| method.split('__').first }
|
19
19
|
|
20
|
-
exchange = get_exchange channel, :events
|
20
|
+
exchange = get_exchange @channel, :events
|
21
21
|
|
22
22
|
methods.uniq.each do |method|
|
23
23
|
routing_key = "events.#{method}"
|
@@ -4,21 +4,15 @@ module Euston
|
|
4
4
|
include Euston::RabbitMq::Queues
|
5
5
|
include Euston::RabbitMq::Exchanges
|
6
6
|
|
7
|
-
def initialize references, logger = Euston::NullLogger.instance
|
7
|
+
def initialize channel, references, logger = Euston::NullLogger.instance
|
8
|
+
@channel = channel
|
8
9
|
@references = references
|
9
10
|
@log = logger
|
10
11
|
end
|
11
12
|
|
12
13
|
def ensure_bindings_exist
|
13
|
-
|
14
|
-
|
15
|
-
channel.prefetch 1
|
16
|
-
|
17
|
-
@references.each do |reference|
|
18
|
-
ensure_bindings_exist_for_reference channel, reference
|
19
|
-
end
|
20
|
-
ensure
|
21
|
-
channel.disconnect unless channel.nil?
|
14
|
+
@references.each do |reference|
|
15
|
+
ensure_bindings_exist_for_reference reference
|
22
16
|
end
|
23
17
|
end
|
24
18
|
end
|
@@ -12,13 +12,13 @@ module Euston
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def subscribe
|
15
|
-
queue.when(:message_decode_failed => method(:log_decode_failure),
|
16
|
-
:message_failed => method(:handle_failure),
|
17
|
-
:message_received => method(:call_handler))
|
18
|
-
|
19
15
|
queue.safe_subscribe
|
20
16
|
end
|
21
17
|
|
18
|
+
def get
|
19
|
+
queue.safe_get
|
20
|
+
end
|
21
|
+
|
22
22
|
private
|
23
23
|
|
24
24
|
def call_handler message
|
@@ -38,7 +38,7 @@ module Euston
|
|
38
38
|
:body =>
|
39
39
|
{
|
40
40
|
:message => failed_message,
|
41
|
-
:routing_key => reactive_message.
|
41
|
+
:routing_key => reactive_message.headers.routing_key,
|
42
42
|
:error => error.message,
|
43
43
|
:backtrace => error.backtrace
|
44
44
|
}
|
@@ -57,13 +57,13 @@ module Euston
|
|
57
57
|
message.delete :failures
|
58
58
|
message = create_message_failed_message error, message, reactive_message
|
59
59
|
|
60
|
-
options = { :
|
60
|
+
options = { :routing_key => 'events.message_failed' }
|
61
61
|
exchange = :events
|
62
62
|
else
|
63
63
|
debug_message = "Message failed, retrying"
|
64
64
|
|
65
|
-
options = { :
|
66
|
-
exchange = reactive_message.
|
65
|
+
options = { :routing_key => reactive_message.headers.routing_key }
|
66
|
+
exchange = reactive_message.headers.routing_key.split('.').first.to_sym
|
67
67
|
end
|
68
68
|
|
69
69
|
options = default_publish_options.merge options
|
@@ -76,21 +76,28 @@ module Euston
|
|
76
76
|
|
77
77
|
reactive_message.ack
|
78
78
|
rescue StandardError => e
|
79
|
-
reactive_message.reject
|
79
|
+
reactive_message.reject
|
80
80
|
raise e
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
84
|
def log_decode_failure message, error
|
85
85
|
text = "A handler queue subscription failed. [Error] #{error.message} [Payload] #{message}"
|
86
|
-
|
87
|
-
|
86
|
+
wrapper = Euston::RabbitMq::MessageDecodeFailedError.new text
|
87
|
+
wrapper.set_backtrace error.backtrace
|
88
88
|
|
89
|
-
raise
|
89
|
+
raise wrapper
|
90
90
|
end
|
91
91
|
|
92
92
|
def queue
|
93
|
-
@queue
|
93
|
+
if @queue.nil?
|
94
|
+
@queue = get_queue @channel, @queue_name
|
95
|
+
@queue.when(:message_decode_failed => method(:log_decode_failure),
|
96
|
+
:message_failed => method(:handle_failure),
|
97
|
+
:message_received => method(:call_handler))
|
98
|
+
end
|
99
|
+
|
100
|
+
@queue
|
94
101
|
end
|
95
102
|
end
|
96
103
|
end
|
@@ -1,19 +1,22 @@
|
|
1
|
-
|
1
|
+
module HotBunnies
|
2
2
|
class Queue
|
3
3
|
include Hollywood
|
4
4
|
|
5
5
|
attr_writer :timeout
|
6
6
|
|
7
|
+
def consumer auto_ack = false
|
8
|
+
consumer = QueueingConsumer.new @channel
|
9
|
+
@channel.basic_consume @name, auto_ack, consumer
|
10
|
+
consumer
|
11
|
+
end
|
12
|
+
|
7
13
|
def delivery_timeout
|
8
14
|
@timeout ||= 500
|
9
15
|
end
|
10
16
|
|
11
|
-
def
|
12
|
-
|
13
|
-
|
14
|
-
until Thread.current[:stop] do
|
15
|
-
safe_subscribe_with_timeout(_consumer, self.delivery_timeout)
|
16
|
-
end
|
17
|
+
def safe_get
|
18
|
+
message = get :ack => true
|
19
|
+
safe_handle_message ReactiveMessage.new(@channel, *message) unless message.nil?
|
17
20
|
end
|
18
21
|
|
19
22
|
def safe_handle_message reactive_message
|
@@ -22,29 +25,33 @@ class RabbitMQClient
|
|
22
25
|
|
23
26
|
begin
|
24
27
|
callback :message_received, message
|
25
|
-
reactive_message.ack
|
28
|
+
reactive_message.ack
|
26
29
|
rescue Euston::EventStore::ConcurrencyError
|
27
|
-
reactive_message.reject
|
30
|
+
reactive_message.reject #requeue
|
28
31
|
rescue => e
|
29
32
|
callback :message_failed, message, e, reactive_message
|
30
|
-
Safely.report! e
|
31
33
|
end
|
32
34
|
rescue => e
|
33
35
|
callback :message_decode_failed, reactive_message.body, e
|
34
|
-
reactive_message.ack
|
36
|
+
reactive_message.ack
|
35
37
|
Safely.report! e
|
36
38
|
end
|
39
|
+
|
40
|
+
reactive_message.headers.ack unless reactive_message.reacted?
|
37
41
|
end
|
38
42
|
|
39
|
-
def
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
+
def safe_subscribe
|
44
|
+
_consumer = self.consumer
|
45
|
+
|
46
|
+
until Thread.current[:stop] do
|
47
|
+
safe_subscribe_with_timeout _consumer, self.delivery_timeout
|
48
|
+
end
|
43
49
|
end
|
44
50
|
|
45
51
|
def safe_subscribe_with_timeout consumer, timeout = 500
|
46
52
|
loop do
|
47
53
|
delivery = nil
|
54
|
+
|
48
55
|
begin
|
49
56
|
delivery = consumer.next_delivery timeout
|
50
57
|
rescue NativeException => e
|
@@ -54,10 +61,11 @@ class RabbitMQClient
|
|
54
61
|
|
55
62
|
break if delivery.nil?
|
56
63
|
|
57
|
-
|
58
|
-
|
64
|
+
headers = Headers.new @channel, nil, delivery.envelope, delivery.properties
|
65
|
+
body = String.from_java_bytes(delivery.get_body)
|
59
66
|
|
60
|
-
@channel
|
67
|
+
reactive_message = ReactiveMessage.new @channel, headers, body
|
68
|
+
safe_handle_message reactive_message
|
61
69
|
end
|
62
70
|
end
|
63
71
|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module HotBunnies
|
2
|
+
class ReactiveMessage
|
3
|
+
attr_reader :headers, :body
|
4
|
+
|
5
|
+
def initialize channel, headers, body
|
6
|
+
@channel = channel
|
7
|
+
@headers = headers
|
8
|
+
@body = body
|
9
|
+
@reacted = false
|
10
|
+
end
|
11
|
+
|
12
|
+
def ack opts = {}
|
13
|
+
@headers.ack({ :multiple => false }.merge(opts))
|
14
|
+
@reacted = true
|
15
|
+
end
|
16
|
+
|
17
|
+
def reject opts = {}
|
18
|
+
@headers.reject({ :requeue => true }.merge(opts))
|
19
|
+
@reacted = true
|
20
|
+
end
|
21
|
+
|
22
|
+
def reacted?
|
23
|
+
@reacted
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,10 +1,11 @@
|
|
1
1
|
module Euston
|
2
2
|
module RabbitMq
|
3
3
|
class HandlerFinder
|
4
|
-
def initialize required_mixins = []
|
4
|
+
def initialize required_mixins = [], logger = Euston::NullLogger.instance
|
5
5
|
@namespaces = []
|
6
6
|
@constant_loader = ConstantLoader.new.when(:hit => method(:store_found_constant), :miss => method(:log_failed_lookup))
|
7
7
|
@required_mixins = required_mixins
|
8
|
+
@log = logger
|
8
9
|
end
|
9
10
|
|
10
11
|
attr_reader :namespaces
|
@@ -32,7 +33,7 @@ module Euston
|
|
32
33
|
end
|
33
34
|
|
34
35
|
def log_failed_lookup string
|
35
|
-
|
36
|
+
@log.warn "Couldn't find handler namespace: #{string}"
|
36
37
|
end
|
37
38
|
|
38
39
|
def map_namespaces_to_references
|
@@ -41,7 +42,7 @@ module Euston
|
|
41
42
|
@namespaces.each do |namespace|
|
42
43
|
references.push *(namespace.constants.map do |constant|
|
43
44
|
reference = HandlerReference.new namespace, namespace.const_get(constant), constant
|
44
|
-
reference = nil unless @required_mixins.
|
45
|
+
reference = nil unless @required_mixins.empty? || @required_mixins.any? { |mixin| reference.handler.included_modules.include? mixin }
|
45
46
|
reference
|
46
47
|
end.to_a - [nil])
|
47
48
|
end
|
data/lib/euston-rabbitmq.rb
CHANGED
@@ -4,7 +4,7 @@ require 'active_support/ordered_hash'
|
|
4
4
|
require 'hash-keys'
|
5
5
|
require 'hollywood'
|
6
6
|
require 'i18n'
|
7
|
-
require '
|
7
|
+
require 'hot_bunnies' if RUBY_PLATFORM == 'java'
|
8
8
|
require 'safely'
|
9
9
|
|
10
10
|
require 'euston'
|
@@ -14,8 +14,8 @@ require 'euston-rabbitmq/reflection/constant_loader'
|
|
14
14
|
require 'euston-rabbitmq/reflection/handler_finder'
|
15
15
|
require 'euston-rabbitmq/reflection/handler_reference'
|
16
16
|
|
17
|
-
require 'euston-rabbitmq/
|
18
|
-
require 'euston-rabbitmq/
|
17
|
+
require 'euston-rabbitmq/hot_bunnies/reactive_message'
|
18
|
+
require 'euston-rabbitmq/hot_bunnies/queue'
|
19
19
|
|
20
20
|
require 'euston-rabbitmq/euston/errors'
|
21
21
|
require 'euston-rabbitmq/euston/exchanges'
|
@@ -12,8 +12,8 @@ describe 'command handler binder', :rabbitmq do
|
|
12
12
|
|
13
13
|
let(:handler) { CommandHandlerBinderTesting::AbcHandler }
|
14
14
|
let(:handler_finder) { Euston::RabbitMq::HandlerFinder.new.tap { |f| f.namespaces.push 'CommandHandlerBinderTesting' } }
|
15
|
-
let(:binder) { Euston::RabbitMq::CommandHandlerBinder.new handler_finder.find }
|
16
|
-
let(:bindings) { @rabbitmqadmin.list_bindings
|
15
|
+
let(:binder) { Euston::RabbitMq::CommandHandlerBinder.new @channel, handler_finder.find }
|
16
|
+
let(:bindings) { @rabbitmqadmin.list_bindings @amqp_config[:vhost] }
|
17
17
|
|
18
18
|
before { binder.ensure_bindings_exist }
|
19
19
|
|
@@ -22,8 +22,8 @@ describe 'event handler binder', :rabbitmq do
|
|
22
22
|
|
23
23
|
let(:handler) { EventHandlerBinderTesting::XyzHandler }
|
24
24
|
let(:handler_finder) { Euston::RabbitMq::HandlerFinder.new.tap { |f| f.namespaces.push 'EventHandlerBinderTesting' } }
|
25
|
-
let(:binder) { Euston::RabbitMq::EventHandlerBinder.new handler_finder.find }
|
26
|
-
let(:bindings) { @rabbitmqadmin.list_bindings
|
25
|
+
let(:binder) { Euston::RabbitMq::EventHandlerBinder.new @channel, handler_finder.find }
|
26
|
+
let(:bindings) { @rabbitmqadmin.list_bindings @amqp_config[:vhost] }
|
27
27
|
|
28
28
|
before { binder.ensure_bindings_exist }
|
29
29
|
|
@@ -13,15 +13,5 @@ describe 'exchanges', :rabbitmq do
|
|
13
13
|
subject { get_exchange @channel, :events }
|
14
14
|
its(:name) { should == 'events' }
|
15
15
|
end
|
16
|
-
|
17
|
-
context 'obtaining the same exchange instance' do
|
18
|
-
let(:name) { "exchange_#{Time.now.to_i}" }
|
19
|
-
let(:instance_1) { get_exchange @channel, name }
|
20
|
-
let(:instance_2) { get_exchange @channel, name }
|
21
|
-
|
22
|
-
subject { instance_1 }
|
23
|
-
|
24
|
-
it { should equal instance_2 }
|
25
|
-
end
|
26
16
|
end
|
27
17
|
end
|
data/spec/euston/queues_spec.rb
CHANGED
@@ -11,14 +11,5 @@ describe 'queues', :rabbitmq do
|
|
11
11
|
|
12
12
|
its(:name) { should == name }
|
13
13
|
end
|
14
|
-
|
15
|
-
context 'obtaining the same queue instance' do
|
16
|
-
let(:instance_1) { get_queue(@channel, name) }
|
17
|
-
let(:instance_2) { get_queue(@channel, name) }
|
18
|
-
|
19
|
-
subject { instance_1 }
|
20
|
-
|
21
|
-
it { should equal instance_2 }
|
22
|
-
end
|
23
14
|
end
|
24
15
|
end
|
@@ -15,13 +15,13 @@ describe 'retrying subscription', :rabbitmq do
|
|
15
15
|
let(:message) { { :x => 123 } }
|
16
16
|
let(:routing_key) { 'events.failing' }
|
17
17
|
let(:error) { 'kablammo' }
|
18
|
+
let(:thread_channel) { @amqp_connection.create_channel }
|
18
19
|
|
19
20
|
before do
|
20
21
|
failing_handler_queue.bind events_exchange, :routing_key => routing_key
|
21
22
|
failed_message_handler_queue.bind events_exchange, :routing_key => 'events.message_failed'
|
22
23
|
|
23
|
-
@thread = Thread.new(failing_queue_name, fail_limit, outcomes) do |name, fail_limit, outcomes|
|
24
|
-
channel = AMQP::Channel.new
|
24
|
+
@thread = Thread.new(thread_channel, failing_queue_name, fail_limit, outcomes) do |channel, name, fail_limit, outcomes|
|
25
25
|
subscription = Euston::RabbitMq::RetryingSubscription.new channel, name
|
26
26
|
subscription.when(:message_received => ->(body) { outcomes[:attempts_to_handle] += 1; raise error if outcomes[:attempts_to_handle] <= fail_limit })
|
27
27
|
subscription.subscribe
|
@@ -31,7 +31,7 @@ describe 'retrying subscription', :rabbitmq do
|
|
31
31
|
failing_message_handler_queue_harness.when(:message_received => ->(body) { outcomes[:failure] = body })
|
32
32
|
failing_message_handler_queue_harness.startup
|
33
33
|
|
34
|
-
events_exchange.publish ActiveSupport::JSON.encode(message), { :
|
34
|
+
events_exchange.publish ActiveSupport::JSON.encode(message), { :routing_key => routing_key }
|
35
35
|
|
36
36
|
sleep 0.25
|
37
37
|
end
|
@@ -39,6 +39,7 @@ describe 'retrying subscription', :rabbitmq do
|
|
39
39
|
after do
|
40
40
|
failing_message_handler_queue_harness.shutdown
|
41
41
|
@thread.kill
|
42
|
+
thread_channel.close
|
42
43
|
end
|
43
44
|
|
44
45
|
subject { outcomes }
|
@@ -24,7 +24,7 @@ describe 'queue', :rabbitmq do
|
|
24
24
|
sleep 0.25
|
25
25
|
end
|
26
26
|
|
27
|
-
let(:exchange) { @channel.
|
27
|
+
let(:exchange) { @channel.exchange "test-#{Time.now.to_i - 1}", :durable => true, :nowait => false, :type => :topic }
|
28
28
|
let(:harness) { QueueSubscriptionThreadHarness.new queue }
|
29
29
|
|
30
30
|
before do
|
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'ap'
|
2
|
+
require 'logger'
|
2
3
|
require 'rabbitmqadmin-cli'
|
3
4
|
require 'euston-rabbitmq'
|
4
5
|
|
@@ -14,21 +15,32 @@ if jruby?
|
|
14
15
|
require File.expand_path('../support/queue_subscription_thread_harness', __FILE__)
|
15
16
|
require File.expand_path('../support/filters', __FILE__)
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
amqp_config = { :host => 'localhost',
|
19
|
+
:pass => 'password',
|
20
|
+
:user => 'euston-rabbitmq-test',
|
21
|
+
:vhost => 'euston-rabbitmq-test' }
|
21
22
|
|
22
23
|
RSpec.configure do |config|
|
23
24
|
config.treat_symbols_as_metadata_keys_with_true_values = true
|
24
25
|
|
25
|
-
config.before(:
|
26
|
-
|
26
|
+
config.before(:all, :rabbitmq) do
|
27
|
+
@amqp_config = amqp_config
|
27
28
|
end
|
28
29
|
|
29
30
|
config.before(:each, :rabbitmq) do
|
30
|
-
initialize_rabbitmq
|
31
|
-
|
31
|
+
initialize_rabbitmq amqp_config
|
32
|
+
|
33
|
+
@amqp_connection = HotBunnies.connect(:host => amqp_config[:host],
|
34
|
+
:virtual_host => amqp_config[:vhost],
|
35
|
+
:username => amqp_config[:user],
|
36
|
+
:password => amqp_config[:pass])
|
37
|
+
|
38
|
+
@channel = @amqp_connection.create_channel
|
39
|
+
end
|
40
|
+
|
41
|
+
config.after(:each, :rabbitmq) do
|
42
|
+
@channel.close
|
43
|
+
@amqp_connection.close
|
32
44
|
end
|
33
45
|
end
|
34
46
|
end
|
data/spec/support/filters.rb
CHANGED
@@ -1,10 +1,5 @@
|
|
1
|
-
def
|
2
|
-
AMQP.settings.merge! AMQP_OPTS
|
3
|
-
@channel = AMQP::Channel.new
|
4
|
-
end
|
5
|
-
|
6
|
-
def initialize_rabbitmq
|
1
|
+
def initialize_rabbitmq amqp_config
|
7
2
|
@rabbitmqadmin = RabbitMqAdminCli.new
|
8
|
-
@rabbitmqadmin.initialize_vhost
|
9
|
-
@rabbitmqadmin.initialize_user
|
3
|
+
@rabbitmqadmin.initialize_vhost amqp_config[:vhost]
|
4
|
+
@rabbitmqadmin.initialize_user amqp_config[:vhost], amqp_config[:user], amqp_config[:pass]
|
10
5
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: euston-rabbitmq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.
|
5
|
+
version: 1.2.0
|
6
6
|
platform: java
|
7
7
|
authors:
|
8
8
|
- Lee Henson
|
@@ -10,139 +10,139 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2011-10-
|
13
|
+
date: 2011-10-12 00:00:00.000000000 +01:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|
18
|
-
version_requirements: &
|
18
|
+
version_requirements: &2210 !ruby/object:Gem::Requirement
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: 3.0.10
|
23
23
|
none: false
|
24
|
-
requirement: *
|
24
|
+
requirement: *2210
|
25
25
|
prerelease: false
|
26
26
|
type: :runtime
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: euston
|
29
|
-
version_requirements: &
|
29
|
+
version_requirements: &2228 !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
33
|
+
version: 1.2.0
|
34
34
|
none: false
|
35
|
-
requirement: *
|
35
|
+
requirement: *2228
|
36
36
|
prerelease: false
|
37
37
|
type: :runtime
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
39
|
name: euston-eventstore
|
40
|
-
version_requirements: &
|
40
|
+
version_requirements: &2244 !ruby/object:Gem::Requirement
|
41
41
|
requirements:
|
42
42
|
- - ~>
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
version: 1.
|
44
|
+
version: 1.2.0
|
45
45
|
none: false
|
46
|
-
requirement: *
|
46
|
+
requirement: *2244
|
47
47
|
prerelease: false
|
48
48
|
type: :runtime
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
50
|
name: hash-keys
|
51
|
-
version_requirements: &
|
51
|
+
version_requirements: &2260 !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - ~>
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: 1.0.0
|
56
56
|
none: false
|
57
|
-
requirement: *
|
57
|
+
requirement: *2260
|
58
58
|
prerelease: false
|
59
59
|
type: :runtime
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: hollywood
|
62
|
-
version_requirements: &
|
62
|
+
version_requirements: &2276 !ruby/object:Gem::Requirement
|
63
63
|
requirements:
|
64
64
|
- - ~>
|
65
65
|
- !ruby/object:Gem::Version
|
66
66
|
version: 1.0.0
|
67
67
|
none: false
|
68
|
-
requirement: *
|
68
|
+
requirement: *2276
|
69
69
|
prerelease: false
|
70
70
|
type: :runtime
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
72
|
name: i18n
|
73
|
-
version_requirements: &
|
73
|
+
version_requirements: &2292 !ruby/object:Gem::Requirement
|
74
74
|
requirements:
|
75
75
|
- - ~>
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: 0.5.0
|
78
78
|
none: false
|
79
|
-
requirement: *
|
79
|
+
requirement: *2292
|
80
80
|
prerelease: false
|
81
81
|
type: :runtime
|
82
82
|
- !ruby/object:Gem::Dependency
|
83
|
-
name:
|
84
|
-
version_requirements: &
|
83
|
+
name: hot_bunnies
|
84
|
+
version_requirements: &2308 !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
86
|
- - ~>
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version: 1.0.
|
88
|
+
version: 1.3.0.pre1
|
89
89
|
none: false
|
90
|
-
requirement: *
|
90
|
+
requirement: *2308
|
91
91
|
prerelease: false
|
92
92
|
type: :runtime
|
93
93
|
- !ruby/object:Gem::Dependency
|
94
94
|
name: safely
|
95
|
-
version_requirements: &
|
95
|
+
version_requirements: &2324 !ruby/object:Gem::Requirement
|
96
96
|
requirements:
|
97
97
|
- - ~>
|
98
98
|
- !ruby/object:Gem::Version
|
99
99
|
version: 0.3.0
|
100
100
|
none: false
|
101
|
-
requirement: *
|
101
|
+
requirement: *2324
|
102
102
|
prerelease: false
|
103
103
|
type: :runtime
|
104
104
|
- !ruby/object:Gem::Dependency
|
105
105
|
name: awesome_print
|
106
|
-
version_requirements: &
|
106
|
+
version_requirements: &2340 !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - ~>
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 0.4.0
|
111
111
|
none: false
|
112
|
-
requirement: *
|
112
|
+
requirement: *2340
|
113
113
|
prerelease: false
|
114
114
|
type: :development
|
115
115
|
- !ruby/object:Gem::Dependency
|
116
116
|
name: fuubar
|
117
|
-
version_requirements: &
|
117
|
+
version_requirements: &2358 !ruby/object:Gem::Requirement
|
118
118
|
requirements:
|
119
119
|
- - ~>
|
120
120
|
- !ruby/object:Gem::Version
|
121
121
|
version: 0.0.0
|
122
122
|
none: false
|
123
|
-
requirement: *
|
123
|
+
requirement: *2358
|
124
124
|
prerelease: false
|
125
125
|
type: :development
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
127
|
name: rabbitmqadmin-cli
|
128
|
-
version_requirements: &
|
128
|
+
version_requirements: &2374 !ruby/object:Gem::Requirement
|
129
129
|
requirements:
|
130
130
|
- - ~>
|
131
131
|
- !ruby/object:Gem::Version
|
132
132
|
version: 1.0.0
|
133
133
|
none: false
|
134
|
-
requirement: *
|
134
|
+
requirement: *2374
|
135
135
|
prerelease: false
|
136
136
|
type: :development
|
137
137
|
- !ruby/object:Gem::Dependency
|
138
138
|
name: rspec
|
139
|
-
version_requirements: &
|
139
|
+
version_requirements: &2390 !ruby/object:Gem::Requirement
|
140
140
|
requirements:
|
141
141
|
- - ~>
|
142
142
|
- !ruby/object:Gem::Version
|
143
143
|
version: 2.6.0
|
144
144
|
none: false
|
145
|
-
requirement: *
|
145
|
+
requirement: *2390
|
146
146
|
prerelease: false
|
147
147
|
type: :development
|
148
148
|
description: JRuby RabbitMq bindings
|
@@ -164,8 +164,8 @@ files:
|
|
164
164
|
- lib/euston-rabbitmq/euston/handler_binder.rb
|
165
165
|
- lib/euston-rabbitmq/euston/queues.rb
|
166
166
|
- lib/euston-rabbitmq/euston/retrying_subscription.rb
|
167
|
-
- lib/euston-rabbitmq/
|
168
|
-
- lib/euston-rabbitmq/
|
167
|
+
- lib/euston-rabbitmq/hot_bunnies/queue.rb
|
168
|
+
- lib/euston-rabbitmq/hot_bunnies/reactive_message.rb
|
169
169
|
- lib/euston-rabbitmq/reflection/constant_loader.rb
|
170
170
|
- lib/euston-rabbitmq/reflection/handler_finder.rb
|
171
171
|
- lib/euston-rabbitmq/reflection/handler_reference.rb
|