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.
Files changed (45) hide show
  1. data/Gemfile +2 -0
  2. data/Rakefile +0 -21
  3. data/euston-rabbitmq.gemspec +26 -37
  4. data/lib/euston-rabbitmq/{bindings → euston}/command_handler_binder.rb +2 -2
  5. data/lib/euston-rabbitmq/{errors.rb → euston/errors.rb} +1 -1
  6. data/lib/euston-rabbitmq/{bindings → euston}/event_handler_binder.rb +4 -4
  7. data/lib/euston-rabbitmq/{exchanges.rb → euston/exchanges.rb} +1 -1
  8. data/lib/euston-rabbitmq/{bindings → euston}/handler_binder.rb +2 -1
  9. data/lib/euston-rabbitmq/{queues.rb → euston/queues.rb} +1 -1
  10. data/lib/euston-rabbitmq/{subscriptions/retriable_subscription.rb → euston/retrying_subscription.rb} +17 -16
  11. data/lib/euston-rabbitmq/rabbitmq_client/queue.rb +70 -0
  12. data/lib/euston-rabbitmq/rabbitmq_client/reactive_message.rb +15 -0
  13. data/lib/euston-rabbitmq/{constant_loader.rb → reflection/constant_loader.rb} +0 -0
  14. data/lib/euston-rabbitmq/{handler_finder.rb → reflection/handler_finder.rb} +0 -0
  15. data/lib/euston-rabbitmq/{handler_reference.rb → reflection/handler_reference.rb} +0 -0
  16. data/lib/euston-rabbitmq/version.rb +1 -1
  17. data/lib/euston-rabbitmq.rb +8 -22
  18. data/spec/euston/command_handler_binder_spec.rb +24 -0
  19. data/spec/euston/event_handler_binder_spec.rb +36 -0
  20. data/spec/euston/exchanges_spec.rb +27 -0
  21. data/spec/euston/queues_spec.rb +24 -0
  22. data/spec/euston/retrying_subscription_spec.rb +74 -0
  23. data/spec/rabbitmq_client/queue_spec.rb +69 -0
  24. data/spec/{constant_loader_spec.rb → reflection/constant_loader_spec.rb} +3 -1
  25. data/spec/{handler_finder_spec.rb → reflection/handler_finder_spec.rb} +3 -1
  26. data/spec/spec_helper.rb +19 -52
  27. data/spec/support/filters.rb +10 -0
  28. data/spec/support/queue_subscription_thread_harness.rb +29 -0
  29. data/spec/support/rabbitmqadmin.rb +74 -0
  30. metadata +58 -117
  31. data/lib/euston-rabbitmq/command_handlers/retry_failed_message.rb +0 -29
  32. data/lib/euston-rabbitmq/event_handlers/message_failure.rb +0 -27
  33. data/lib/euston-rabbitmq/message_buffer.rb +0 -67
  34. data/lib/euston-rabbitmq/message_logger.rb +0 -50
  35. data/lib/euston-rabbitmq/queue.rb +0 -30
  36. data/lib/euston-rabbitmq/read_model/failed_message.rb +0 -36
  37. data/lib/euston-rabbitmq/read_model/message_buffer.rb +0 -57
  38. data/lib/euston-rabbitmq/read_model/message_log.rb +0 -37
  39. data/spec/command_buffer_spec.rb +0 -69
  40. data/spec/event_buffer_spec.rb +0 -69
  41. data/spec/exchange_declaration_spec.rb +0 -28
  42. data/spec/message_failure_spec.rb +0 -77
  43. data/spec/mt_safe_queue_subscription_spec.rb +0 -72
  44. data/spec/safe_queue_subscription_spec.rb +0 -50
  45. data/spec/support/factories.rb +0 -18
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: euston-rabbitmq
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-09-20 00:00:00.000000000 Z
13
+ date: 2011-09-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
17
- requirement: &79361210 !ruby/object:Gem::Requirement
17
+ requirement: &81151090 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,21 +22,21 @@ dependencies:
22
22
  version: 3.0.0
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *79361210
25
+ version_requirements: *81151090
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: euston
28
- requirement: &79360880 !ruby/object:Gem::Requirement
28
+ requirement: &81150800 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: 1.0.0
33
+ version: 1.0.1
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *79360880
36
+ version_requirements: *81150800
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: euston-eventstore
39
- requirement: &79360360 !ruby/object:Gem::Requirement
39
+ requirement: &81150430 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 1.0.0
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *79360360
47
+ version_requirements: *81150430
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: hash-keys
50
- requirement: &79359860 !ruby/object:Gem::Requirement
50
+ requirement: &81150040 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ~>
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: 1.0.0
56
56
  type: :runtime
57
57
  prerelease: false
58
- version_requirements: *79359860
58
+ version_requirements: *81150040
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: hollywood
61
- requirement: &79359520 !ruby/object:Gem::Requirement
61
+ requirement: &81149590 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ~>
@@ -66,98 +66,54 @@ dependencies:
66
66
  version: 1.0.0
67
67
  type: :runtime
68
68
  prerelease: false
69
- version_requirements: *79359520
69
+ version_requirements: *81149590
70
70
  - !ruby/object:Gem::Dependency
71
- name: require_all
72
- requirement: &79359140 !ruby/object:Gem::Requirement
71
+ name: i18n
72
+ requirement: &81149160 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
- version: 1.2.0
77
+ version: 0.6.0
78
78
  type: :runtime
79
79
  prerelease: false
80
- version_requirements: *79359140
80
+ version_requirements: *81149160
81
81
  - !ruby/object:Gem::Dependency
82
- name: robustthread
83
- requirement: &79358710 !ruby/object:Gem::Requirement
84
- none: false
85
- requirements:
86
- - - ~>
87
- - !ruby/object:Gem::Version
88
- version: 0.5.2
89
- type: :runtime
90
- prerelease: false
91
- version_requirements: *79358710
92
- - !ruby/object:Gem::Dependency
93
- name: safely
94
- requirement: &79358290 !ruby/object:Gem::Requirement
95
- none: false
96
- requirements:
97
- - - ~>
98
- - !ruby/object:Gem::Version
99
- version: 0.3.0
100
- type: :runtime
101
- prerelease: false
102
- version_requirements: *79358290
103
- - !ruby/object:Gem::Dependency
104
- name: amqp
105
- requirement: &79357840 !ruby/object:Gem::Requirement
106
- none: false
107
- requirements:
108
- - - ~>
109
- - !ruby/object:Gem::Version
110
- version: 0.8.0
111
- type: :runtime
112
- prerelease: false
113
- version_requirements: *79357840
114
- - !ruby/object:Gem::Dependency
115
- name: bson_ext
116
- requirement: &79357520 !ruby/object:Gem::Requirement
82
+ name: require_all
83
+ requirement: &81148290 !ruby/object:Gem::Requirement
117
84
  none: false
118
85
  requirements:
119
86
  - - ~>
120
87
  - !ruby/object:Gem::Version
121
- version: 1.3.1
88
+ version: 1.2.0
122
89
  type: :runtime
123
90
  prerelease: false
124
- version_requirements: *79357520
91
+ version_requirements: *81148290
125
92
  - !ruby/object:Gem::Dependency
126
- name: eventmachine
127
- requirement: &79357270 !ruby/object:Gem::Requirement
93
+ name: robustthread
94
+ requirement: &81147590 !ruby/object:Gem::Requirement
128
95
  none: false
129
96
  requirements:
130
97
  - - ~>
131
98
  - !ruby/object:Gem::Version
132
- version: 0.12.10
99
+ version: 0.5.2
133
100
  type: :runtime
134
101
  prerelease: false
135
- version_requirements: *79357270
102
+ version_requirements: *81147590
136
103
  - !ruby/object:Gem::Dependency
137
- name: mongo
138
- requirement: &79356960 !ruby/object:Gem::Requirement
104
+ name: safely
105
+ requirement: &81145710 !ruby/object:Gem::Requirement
139
106
  none: false
140
107
  requirements:
141
108
  - - ~>
142
109
  - !ruby/object:Gem::Version
143
- version: 1.3.1
110
+ version: 0.3.0
144
111
  type: :runtime
145
112
  prerelease: false
146
- version_requirements: *79356960
147
- - !ruby/object:Gem::Dependency
148
- name: evented-spec
149
- requirement: &79356660 !ruby/object:Gem::Requirement
150
- none: false
151
- requirements:
152
- - - ~>
153
- - !ruby/object:Gem::Version
154
- version: 0.9.0
155
- type: :development
156
- prerelease: false
157
- version_requirements: *79356660
113
+ version_requirements: *81145710
158
114
  - !ruby/object:Gem::Dependency
159
115
  name: awesome_print
160
- requirement: &79356350 !ruby/object:Gem::Requirement
116
+ requirement: &81145150 !ruby/object:Gem::Requirement
161
117
  none: false
162
118
  requirements:
163
119
  - - ~>
@@ -165,21 +121,10 @@ dependencies:
165
121
  version: 0.4.0
166
122
  type: :development
167
123
  prerelease: false
168
- version_requirements: *79356350
169
- - !ruby/object:Gem::Dependency
170
- name: faker
171
- requirement: &79355980 !ruby/object:Gem::Requirement
172
- none: false
173
- requirements:
174
- - - ~>
175
- - !ruby/object:Gem::Version
176
- version: 1.0.0
177
- type: :development
178
- prerelease: false
179
- version_requirements: *79355980
124
+ version_requirements: *81145150
180
125
  - !ruby/object:Gem::Dependency
181
126
  name: fuubar
182
- requirement: &79355660 !ruby/object:Gem::Requirement
127
+ requirement: &81144320 !ruby/object:Gem::Requirement
183
128
  none: false
184
129
  requirements:
185
130
  - - ~>
@@ -187,10 +132,10 @@ dependencies:
187
132
  version: 0.0.0
188
133
  type: :development
189
134
  prerelease: false
190
- version_requirements: *79355660
135
+ version_requirements: *81144320
191
136
  - !ruby/object:Gem::Dependency
192
137
  name: rspec
193
- requirement: &79355170 !ruby/object:Gem::Requirement
138
+ requirement: &81143950 !ruby/object:Gem::Requirement
194
139
  none: false
195
140
  requirements:
196
141
  - - ~>
@@ -198,7 +143,7 @@ dependencies:
198
143
  version: 2.6.0
199
144
  type: :development
200
145
  prerelease: false
201
- version_requirements: *79355170
146
+ version_requirements: *81143950
202
147
  description: JRuby RabbitMq bindings
203
148
  email:
204
149
  - lee.m.henson@gmail.com
@@ -211,35 +156,31 @@ files:
211
156
  - Rakefile
212
157
  - euston-rabbitmq.gemspec
213
158
  - lib/euston-rabbitmq.rb
214
- - lib/euston-rabbitmq/bindings/command_handler_binder.rb
215
- - lib/euston-rabbitmq/bindings/event_handler_binder.rb
216
- - lib/euston-rabbitmq/bindings/handler_binder.rb
217
- - lib/euston-rabbitmq/command_handlers/retry_failed_message.rb
218
- - lib/euston-rabbitmq/constant_loader.rb
219
- - lib/euston-rabbitmq/errors.rb
220
- - lib/euston-rabbitmq/event_handlers/message_failure.rb
221
- - lib/euston-rabbitmq/exchanges.rb
222
- - lib/euston-rabbitmq/handler_finder.rb
223
- - lib/euston-rabbitmq/handler_reference.rb
224
- - lib/euston-rabbitmq/message_buffer.rb
225
- - lib/euston-rabbitmq/message_logger.rb
226
- - lib/euston-rabbitmq/queue.rb
227
- - lib/euston-rabbitmq/queues.rb
228
- - lib/euston-rabbitmq/read_model/failed_message.rb
229
- - lib/euston-rabbitmq/read_model/message_buffer.rb
230
- - lib/euston-rabbitmq/read_model/message_log.rb
231
- - lib/euston-rabbitmq/subscriptions/retriable_subscription.rb
159
+ - lib/euston-rabbitmq/euston/command_handler_binder.rb
160
+ - lib/euston-rabbitmq/euston/errors.rb
161
+ - lib/euston-rabbitmq/euston/event_handler_binder.rb
162
+ - lib/euston-rabbitmq/euston/exchanges.rb
163
+ - lib/euston-rabbitmq/euston/handler_binder.rb
164
+ - lib/euston-rabbitmq/euston/queues.rb
165
+ - lib/euston-rabbitmq/euston/retrying_subscription.rb
166
+ - lib/euston-rabbitmq/rabbitmq_client/queue.rb
167
+ - lib/euston-rabbitmq/rabbitmq_client/reactive_message.rb
168
+ - lib/euston-rabbitmq/reflection/constant_loader.rb
169
+ - lib/euston-rabbitmq/reflection/handler_finder.rb
170
+ - lib/euston-rabbitmq/reflection/handler_reference.rb
232
171
  - lib/euston-rabbitmq/version.rb
233
- - spec/command_buffer_spec.rb
234
- - spec/constant_loader_spec.rb
235
- - spec/event_buffer_spec.rb
236
- - spec/exchange_declaration_spec.rb
237
- - spec/handler_finder_spec.rb
238
- - spec/message_failure_spec.rb
239
- - spec/mt_safe_queue_subscription_spec.rb
240
- - spec/safe_queue_subscription_spec.rb
172
+ - spec/euston/command_handler_binder_spec.rb
173
+ - spec/euston/event_handler_binder_spec.rb
174
+ - spec/euston/exchanges_spec.rb
175
+ - spec/euston/queues_spec.rb
176
+ - spec/euston/retrying_subscription_spec.rb
177
+ - spec/rabbitmq_client/queue_spec.rb
178
+ - spec/reflection/constant_loader_spec.rb
179
+ - spec/reflection/handler_finder_spec.rb
241
180
  - spec/spec_helper.rb
242
- - spec/support/factories.rb
181
+ - spec/support/filters.rb
182
+ - spec/support/queue_subscription_thread_harness.rb
183
+ - spec/support/rabbitmqadmin.rb
243
184
  homepage: http://github.com/leemhenson/euston-rabbitmq
244
185
  licenses: []
245
186
  post_install_message:
@@ -1,29 +0,0 @@
1
- module Euston
2
- module RabbitMq
3
- module CommandHandlers
4
- class RetryFailedMessage
5
- include Euston::CommandHandler
6
-
7
- version 1 do |headers, command|
8
- model = Euston::RabbitMq::ReadModel::FailedMessage.new
9
- message = model.get_by_id command[:id]
10
-
11
- unless message.nil?
12
- routing_key = message['routing_key']
13
- exchange = routing_key.split('.').first
14
-
15
- headers = message['headers'].merge(:id => command[:id],
16
- :type => message['type'],
17
- :version => message['version'] )
18
-
19
- buffer = Euston::RabbitMq::MessageBuffer.send("#{exchange}_buffer")
20
- buffer.push :headers => headers,
21
- :body => message['body']
22
-
23
- model.remove_by_id command[:id]
24
- end
25
- end
26
- end
27
- end
28
- end
29
- end
@@ -1,27 +0,0 @@
1
- module Euston
2
- module RabbitMq
3
- module EventHandlers
4
- class MessageFailure
5
- include Euston::EventHandler
6
-
7
- consumes :message_failed, 1 do |headers, event|
8
- headers = event[:message][:headers].dup
9
- failure = { :message_id => headers.delete(:id),
10
- :type => headers.delete(:type),
11
- :version => headers.delete(:version),
12
- :message_timestamp => headers.delete(:timestamp),
13
- :routing_key => event[:routing_key],
14
- :body => event[:message][:body],
15
- :headers => headers,
16
- :error => event[:error],
17
- :backtrace => event[:backtrace],
18
- :failure_timestamp => Time.now.to_f }
19
-
20
- model = Euston::RabbitMq::ReadModel::FailedMessage
21
- model = model.new
22
- model.log_failure failure
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,67 +0,0 @@
1
- module Euston
2
- module RabbitMq
3
- class MessageBuffer
4
- class << self
5
- def commands_buffer channel = nil
6
- @command_buffers ||= MessageBuffer.new channel, :commands
7
- end
8
-
9
- def events_buffer channel = nil
10
- @event_buffers ||= MessageBuffer.new channel, :events
11
- end
12
- end
13
-
14
- include Euston::RabbitMq::Exchanges
15
- include Euston::RabbitMq::Queues
16
- include Hollywood
17
-
18
- def initialize channel, exchange_name
19
- @channel = channel
20
- @exchange = get_exchange channel, exchange_name
21
- @read_model = Euston::RabbitMq::ReadModel::MessageBuffer.send exchange_name
22
-
23
- @queue = get_queue channel, "#{exchange_name}_buffer"
24
- @queue.bind @exchange, :routing_key => "#{exchange_name}.#"
25
-
26
- @queue.when(:message_decode_failed => method(:log_failure),
27
- :message_failed => method(:handle_failure),
28
- :message_received => method(:remove_message_from_buffer))
29
-
30
- @queue.safe_subscribe
31
- end
32
-
33
- def handle_failure(message, error, header)
34
- log_failure message, error
35
- header.ack
36
- end
37
-
38
- def dispatch_due_messages
39
- dispatched = false
40
-
41
- @read_model.find_due_messages.to_a.each do |message|
42
- @read_model.set_next_attempt message
43
- @exchange.publish message['json'], default_publish_options.merge(:routing_key => "#{@exchange.name}.#{message['type']}")
44
- dispatched = true
45
- end
46
-
47
- callback(:no_messages_were_due) unless dispatched
48
- end
49
-
50
- def log_failure message, error
51
- text = "A buffer queue subscription failed. [Error] #{error.message} [Payload] #{message}"
52
- err = Euston::RabbitMq::MessageDecodeFailedError.new text
53
- err.set_backtrace error.backtrace
54
-
55
- Safely.report! err
56
- end
57
-
58
- def push message
59
- @read_model.buffer_new_message message
60
- end
61
-
62
- def remove_message_from_buffer message
63
- @read_model.remove_published_message message[:headers][:id]
64
- end
65
- end
66
- end
67
- end
@@ -1,50 +0,0 @@
1
- module Euston
2
- module RabbitMq
3
- class MessageLogger
4
- class << self
5
- def commands_logger channel = nil
6
- @command_logger ||= MessageLogger.new channel, :commands
7
- end
8
-
9
- def events_logger channel = nil
10
- @event_logger ||= MessageLogger.new channel, :events
11
- end
12
- end
13
-
14
- include Euston::RabbitMq::Exchanges
15
- include Euston::RabbitMq::Queues
16
-
17
- def initialize channel, exchange_name
18
- @channel = channel
19
- @exchange = get_exchange channel, exchange_name
20
- @read_model = Euston::RabbitMq::ReadModel::MessageLog.send exchange_name
21
-
22
- @queue = get_queue channel, "#{exchange_name}_log"
23
- @queue.bind @exchange, :routing_key => "#{exchange_name}.#"
24
-
25
- @queue.when(:message_decode_failed => method(:log_failure),
26
- :message_failed => method(:handle_failure),
27
- :message_received => method(:write_message_to_log))
28
-
29
- @queue.safe_subscribe
30
- end
31
-
32
- def handle_failure(message, error, header)
33
- log_failure message, error
34
- header.ack
35
- end
36
-
37
- def log_failure message, error
38
- text = "A log queue subscription failed. [Error] #{error.message} [Payload] #{message}"
39
- err = Euston::RabbitMq::MessageDecodeFailedError.new text
40
- err.set_backtrace error.backtrace
41
-
42
- Safely.report! err
43
- end
44
-
45
- def write_message_to_log message
46
- @read_model.log_new_message message
47
- end
48
- end
49
- end
50
- end