euston-rabbitmq 1.0.1-java → 1.0.2-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/Gemfile +2 -0
  2. data/Rakefile +0 -21
  3. data/euston-rabbitmq.gemspec +26 -38
  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 +60 -76
  31. data/Gemfile.lock +0 -76
  32. data/lib/euston-rabbitmq/command_handlers/retry_failed_message.rb +0 -29
  33. data/lib/euston-rabbitmq/event_handlers/message_failure.rb +0 -27
  34. data/lib/euston-rabbitmq/message_buffer.rb +0 -67
  35. data/lib/euston-rabbitmq/message_logger.rb +0 -50
  36. data/lib/euston-rabbitmq/queue.rb +0 -30
  37. data/lib/euston-rabbitmq/read_model/failed_message.rb +0 -36
  38. data/lib/euston-rabbitmq/read_model/message_buffer.rb +0 -57
  39. data/lib/euston-rabbitmq/read_model/message_log.rb +0 -37
  40. data/spec/command_buffer_spec.rb +0 -69
  41. data/spec/event_buffer_spec.rb +0 -69
  42. data/spec/exchange_declaration_spec.rb +0 -28
  43. data/spec/message_failure_spec.rb +0 -77
  44. data/spec/mt_safe_queue_subscription_spec.rb +0 -72
  45. data/spec/safe_queue_subscription_spec.rb +0 -50
  46. data/spec/support/factories.rb +0 -18
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: euston-rabbitmq
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.1
5
+ version: 1.0.2
6
6
  platform: java
7
7
  authors:
8
8
  - Lee Henson
@@ -10,161 +10,150 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-09-20 00:00:00.000000000 +01:00
13
+ date: 2011-09-27 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: &2158 !ruby/object:Gem::Requirement
18
+ version_requirements: &2166 !ruby/object:Gem::Requirement
19
19
  requirements:
20
20
  - - ~>
21
21
  - !ruby/object:Gem::Version
22
22
  version: 3.0.0
23
23
  none: false
24
- requirement: *2158
24
+ requirement: *2166
25
25
  prerelease: false
26
26
  type: :runtime
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: euston
29
- version_requirements: &2176 !ruby/object:Gem::Requirement
29
+ version_requirements: &2184 !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: 1.0.0
33
+ version: 1.0.1
34
34
  none: false
35
- requirement: *2176
35
+ requirement: *2184
36
36
  prerelease: false
37
37
  type: :runtime
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: euston-eventstore
40
- version_requirements: &2192 !ruby/object:Gem::Requirement
40
+ version_requirements: &2200 !ruby/object:Gem::Requirement
41
41
  requirements:
42
42
  - - ~>
43
43
  - !ruby/object:Gem::Version
44
44
  version: 1.0.0
45
45
  none: false
46
- requirement: *2192
46
+ requirement: *2200
47
47
  prerelease: false
48
48
  type: :runtime
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: hash-keys
51
- version_requirements: &2208 !ruby/object:Gem::Requirement
51
+ version_requirements: &2216 !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: *2208
57
+ requirement: *2216
58
58
  prerelease: false
59
59
  type: :runtime
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: hollywood
62
- version_requirements: &2224 !ruby/object:Gem::Requirement
62
+ version_requirements: &2232 !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: *2224
68
+ requirement: *2232
69
69
  prerelease: false
70
70
  type: :runtime
71
71
  - !ruby/object:Gem::Dependency
72
- name: require_all
73
- version_requirements: &2240 !ruby/object:Gem::Requirement
72
+ name: i18n
73
+ version_requirements: &2248 !ruby/object:Gem::Requirement
74
74
  requirements:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
- version: 1.2.0
77
+ version: 0.6.0
78
78
  none: false
79
- requirement: *2240
79
+ requirement: *2248
80
80
  prerelease: false
81
81
  type: :runtime
82
82
  - !ruby/object:Gem::Dependency
83
- name: robustthread
84
- version_requirements: &2256 !ruby/object:Gem::Requirement
83
+ name: require_all
84
+ version_requirements: &2264 !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - ~>
87
87
  - !ruby/object:Gem::Version
88
- version: 0.5.2
88
+ version: 1.2.0
89
89
  none: false
90
- requirement: *2256
90
+ requirement: *2264
91
91
  prerelease: false
92
92
  type: :runtime
93
93
  - !ruby/object:Gem::Dependency
94
- name: safely
95
- version_requirements: &2272 !ruby/object:Gem::Requirement
94
+ name: robustthread
95
+ version_requirements: &2280 !ruby/object:Gem::Requirement
96
96
  requirements:
97
97
  - - ~>
98
98
  - !ruby/object:Gem::Version
99
- version: 0.3.0
99
+ version: 0.5.2
100
100
  none: false
101
- requirement: *2272
101
+ requirement: *2280
102
102
  prerelease: false
103
103
  type: :runtime
104
104
  - !ruby/object:Gem::Dependency
105
- name: jmongo
106
- version_requirements: &2288 !ruby/object:Gem::Requirement
105
+ name: safely
106
+ version_requirements: &2296 !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - ~>
109
109
  - !ruby/object:Gem::Version
110
- version: 1.0.0
110
+ version: 0.3.0
111
111
  none: false
112
- requirement: *2288
112
+ requirement: *2296
113
113
  prerelease: false
114
114
  type: :runtime
115
115
  - !ruby/object:Gem::Dependency
116
116
  name: jessica
117
- version_requirements: &2304 !ruby/object:Gem::Requirement
117
+ version_requirements: &2312 !ruby/object:Gem::Requirement
118
118
  requirements:
119
119
  - - ~>
120
120
  - !ruby/object:Gem::Version
121
121
  version: 1.0.0
122
122
  none: false
123
- requirement: *2304
123
+ requirement: *2312
124
124
  prerelease: false
125
125
  type: :runtime
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: awesome_print
128
- version_requirements: &2320 !ruby/object:Gem::Requirement
128
+ version_requirements: &2328 !ruby/object:Gem::Requirement
129
129
  requirements:
130
130
  - - ~>
131
131
  - !ruby/object:Gem::Version
132
132
  version: 0.4.0
133
133
  none: false
134
- requirement: *2320
135
- prerelease: false
136
- type: :development
137
- - !ruby/object:Gem::Dependency
138
- name: faker
139
- version_requirements: &2338 !ruby/object:Gem::Requirement
140
- requirements:
141
- - - ~>
142
- - !ruby/object:Gem::Version
143
- version: 1.0.0
144
- none: false
145
- requirement: *2338
134
+ requirement: *2328
146
135
  prerelease: false
147
136
  type: :development
148
137
  - !ruby/object:Gem::Dependency
149
138
  name: fuubar
150
- version_requirements: &2354 !ruby/object:Gem::Requirement
139
+ version_requirements: &2346 !ruby/object:Gem::Requirement
151
140
  requirements:
152
141
  - - ~>
153
142
  - !ruby/object:Gem::Version
154
143
  version: 0.0.0
155
144
  none: false
156
- requirement: *2354
145
+ requirement: *2346
157
146
  prerelease: false
158
147
  type: :development
159
148
  - !ruby/object:Gem::Dependency
160
149
  name: rspec
161
- version_requirements: &2370 !ruby/object:Gem::Requirement
150
+ version_requirements: &2362 !ruby/object:Gem::Requirement
162
151
  requirements:
163
152
  - - ~>
164
153
  - !ruby/object:Gem::Version
165
154
  version: 2.6.0
166
155
  none: false
167
- requirement: *2370
156
+ requirement: *2362
168
157
  prerelease: false
169
158
  type: :development
170
159
  description: JRuby RabbitMq bindings
@@ -176,39 +165,34 @@ extensions: []
176
165
  extra_rdoc_files: []
177
166
  files:
178
167
  - Gemfile
179
- - Gemfile.lock
180
168
  - Rakefile
181
169
  - euston-rabbitmq.gemspec
182
170
  - lib/euston-rabbitmq.rb
183
- - lib/euston-rabbitmq/bindings/command_handler_binder.rb
184
- - lib/euston-rabbitmq/bindings/event_handler_binder.rb
185
- - lib/euston-rabbitmq/bindings/handler_binder.rb
186
- - lib/euston-rabbitmq/command_handlers/retry_failed_message.rb
187
- - lib/euston-rabbitmq/constant_loader.rb
188
- - lib/euston-rabbitmq/errors.rb
189
- - lib/euston-rabbitmq/event_handlers/message_failure.rb
190
- - lib/euston-rabbitmq/exchanges.rb
191
- - lib/euston-rabbitmq/handler_finder.rb
192
- - lib/euston-rabbitmq/handler_reference.rb
193
- - lib/euston-rabbitmq/message_buffer.rb
194
- - lib/euston-rabbitmq/message_logger.rb
195
- - lib/euston-rabbitmq/queue.rb
196
- - lib/euston-rabbitmq/queues.rb
197
- - lib/euston-rabbitmq/read_model/failed_message.rb
198
- - lib/euston-rabbitmq/read_model/message_buffer.rb
199
- - lib/euston-rabbitmq/read_model/message_log.rb
200
- - lib/euston-rabbitmq/subscriptions/retriable_subscription.rb
171
+ - lib/euston-rabbitmq/euston/command_handler_binder.rb
172
+ - lib/euston-rabbitmq/euston/errors.rb
173
+ - lib/euston-rabbitmq/euston/event_handler_binder.rb
174
+ - lib/euston-rabbitmq/euston/exchanges.rb
175
+ - lib/euston-rabbitmq/euston/handler_binder.rb
176
+ - lib/euston-rabbitmq/euston/queues.rb
177
+ - lib/euston-rabbitmq/euston/retrying_subscription.rb
178
+ - lib/euston-rabbitmq/rabbitmq_client/queue.rb
179
+ - lib/euston-rabbitmq/rabbitmq_client/reactive_message.rb
180
+ - lib/euston-rabbitmq/reflection/constant_loader.rb
181
+ - lib/euston-rabbitmq/reflection/handler_finder.rb
182
+ - lib/euston-rabbitmq/reflection/handler_reference.rb
201
183
  - lib/euston-rabbitmq/version.rb
202
- - spec/command_buffer_spec.rb
203
- - spec/constant_loader_spec.rb
204
- - spec/event_buffer_spec.rb
205
- - spec/exchange_declaration_spec.rb
206
- - spec/handler_finder_spec.rb
207
- - spec/message_failure_spec.rb
208
- - spec/mt_safe_queue_subscription_spec.rb
209
- - spec/safe_queue_subscription_spec.rb
184
+ - spec/euston/command_handler_binder_spec.rb
185
+ - spec/euston/event_handler_binder_spec.rb
186
+ - spec/euston/exchanges_spec.rb
187
+ - spec/euston/queues_spec.rb
188
+ - spec/euston/retrying_subscription_spec.rb
189
+ - spec/rabbitmq_client/queue_spec.rb
190
+ - spec/reflection/constant_loader_spec.rb
191
+ - spec/reflection/handler_finder_spec.rb
210
192
  - spec/spec_helper.rb
211
- - spec/support/factories.rb
193
+ - spec/support/filters.rb
194
+ - spec/support/queue_subscription_thread_harness.rb
195
+ - spec/support/rabbitmqadmin.rb
212
196
  has_rdoc: true
213
197
  homepage: http://github.com/leemhenson/euston-rabbitmq
214
198
  licenses: []
data/Gemfile.lock DELETED
@@ -1,76 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- euston-rabbitmq (1.0.0-java)
5
- activesupport (~> 3.0.0)
6
- euston (~> 1.0.0)
7
- euston-eventstore (~> 1.0.0)
8
- hash-keys (~> 1.0.0)
9
- hollywood (~> 1.0.0)
10
- jessica (~> 1.0.0)
11
- jmongo (~> 1.0.0)
12
- require_all (~> 1.2.0)
13
- robustthread (~> 0.5.2)
14
- safely (~> 0.3.0)
15
-
16
- GEM
17
- remote: http://rubygems.org/
18
- specs:
19
- activesupport (3.0.10)
20
- awesome_print (0.4.0)
21
- diff-lcs (1.1.3)
22
- euston (1.0.0)
23
- activesupport (~> 3.0.9)
24
- euston-eventstore (~> 1.0.0)
25
- require_all (~> 1.2.0)
26
- euston-eventstore (1.0.4-java)
27
- activesupport (~> 3.0.9)
28
- hash-keys (~> 1.0.0)
29
- jmongo (~> 1.0.0)
30
- json-jruby (~> 1.5.0)
31
- require_all (~> 1.2.0)
32
- uuid (~> 2.3.0)
33
- faker (1.0.0)
34
- i18n (~> 0.4)
35
- fuubar (0.0.6)
36
- rspec (~> 2.0)
37
- rspec-instafail (~> 0.1.8)
38
- ruby-progressbar (~> 0.0.10)
39
- hash-keys (1.0.0)
40
- hollywood (1.0.0)
41
- i18n (0.6.0)
42
- jessica (1.0.2-java)
43
- require_all (~> 1.2.0)
44
- jmongo (1.0.3)
45
- require_all (~> 1.2)
46
- json (1.5.0-java)
47
- json-jruby (1.5.0-java)
48
- json (= 1.5.0)
49
- macaddr (1.4.0)
50
- systemu (~> 2.2.0)
51
- require_all (1.2.0)
52
- robustthread (0.5.2)
53
- rspec (2.6.0)
54
- rspec-core (~> 2.6.0)
55
- rspec-expectations (~> 2.6.0)
56
- rspec-mocks (~> 2.6.0)
57
- rspec-core (2.6.4)
58
- rspec-expectations (2.6.0)
59
- diff-lcs (~> 1.1.2)
60
- rspec-instafail (0.1.8)
61
- rspec-mocks (2.6.0)
62
- ruby-progressbar (0.0.10)
63
- safely (0.3.0)
64
- systemu (2.2.0)
65
- uuid (2.3.4)
66
- macaddr (~> 1.0)
67
-
68
- PLATFORMS
69
- java
70
-
71
- DEPENDENCIES
72
- awesome_print (~> 0.4.0)
73
- euston-rabbitmq!
74
- faker (~> 1.0.0)
75
- fuubar (~> 0.0.0)
76
- rspec (~> 2.6.0)
@@ -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