action_subscriber 5.0.3.pre1 → 5.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0ca7cccf89023f06ddaa142cc7d9ad152857dff0
4
- data.tar.gz: f8c77d9e20ec595946f9bb93e58b316007726ed0
3
+ metadata.gz: 605d2e8c1c46efca8695b90fdefca1b88342bc62
4
+ data.tar.gz: e6a8b84e0fa197c5e085251964f75a362b7d324b
5
5
  SHA512:
6
- metadata.gz: e2b75379c1de445dfe3febfdd980b6fcbca36ec3b6ea968bda1f5f8c17deee0f2e1af98e51f5a0bcbf022041f47ba0621c8e7efc6885c46dc22e66e79e01a772
7
- data.tar.gz: 26f142393ae73dcc8dbddd96150e65d87793265e9c4f9f42052e933de9b1a4c7f724d2994a939c938bde5081ec86fca8ca1315012ac54504057bb7dd5a6eba71
6
+ metadata.gz: d138a4b1709e7d0450b8a3c2cf85a9348ed4e4c8acbfbef61f69a9ea25beeba0fc88924ba46cc286a26ad527877d3b51a2b18dc0b5d3930033f3c1aedce5954a
7
+ data.tar.gz: 566f397bcdbfc28242451be5c6551dc6a013f8e1b7e36aac271ea1afe07ebfbd3ae14d5425f15af2a84645b6d2828a0e33830192f9b1dfd250c30e4823f303fa
@@ -9,10 +9,9 @@ module ActionSubscriber
9
9
  !!@_at_least_once
10
10
  end
11
11
 
12
- def at_most_once!(ack_every_n_messages = 1)
12
+ def at_most_once!
13
13
  @_acknowledge_messages = true
14
14
  @_at_most_once = true
15
- @_ack_every_n_messages = ack_every_n_messages
16
15
  end
17
16
 
18
17
  def at_most_once?
@@ -55,10 +54,6 @@ module ActionSubscriber
55
54
  !!@_manual_acknowedgement
56
55
  end
57
56
 
58
- def ack_every_n_messages
59
- @_ack_every_n_messages || 1
60
- end
61
-
62
57
  def no_acknowledgement!
63
58
  @_acknowledge_messages = false
64
59
  end
@@ -136,41 +131,6 @@ module ActionSubscriber
136
131
  end
137
132
  end
138
133
 
139
- def _run_action_at_most_once_multiple_with_filters(env, action)
140
- processed_acknowledgement = false
141
- rejected_message = false
142
- if env.delivery_tag % ack_every_n_messages == 0 # tags are monotonically increasing integers
143
- processed_acknowledgement = env.acknowledge(true)
144
- else
145
- processed_acknowledgement = true # we are not acknowledging on this message and will wait for the offset to acknowledge
146
- end
147
-
148
- _run_action_with_filters(env, action)
149
- ensure
150
- rejected_message = env.reject if !processed_acknowledgement
151
-
152
- if !rejected_message && !processed_acknowledgement
153
- $stdout << <<-UNREJECTABLE
154
- CANNOT ACKNOWLEDGE OR REJECT THE MESSAGE
155
-
156
- This is a exceptional state for ActionSubscriber to enter and puts the current
157
- Process in the position of "I can't get new work from RabbitMQ, but also
158
- can't acknowledge or reject the work that I currently have" ... While rare
159
- this state can happen.
160
-
161
- Instead of continuing to try to process the message ActionSubscriber is
162
- sending a Kill signal to the current running process to gracefully shutdown
163
- so that the RabbitMQ server will purge any outstanding acknowledgements. If
164
- you are running a process monitoring tool (like Upstart) the Subscriber
165
- process will be restarted and be able to take on new work.
166
-
167
- ** Running a process monitoring tool like Upstart is recommended for this reason **
168
- UNREJECTABLE
169
-
170
- Process.kill(:TERM, Process.pid)
171
- end
172
- end
173
-
174
134
  def _run_action_at_least_once_with_filters(env, action)
175
135
  processed_acknowledgement = false
176
136
  rejected_message = false
@@ -212,10 +172,8 @@ module ActionSubscriber
212
172
  case
213
173
  when at_least_once?
214
174
  _run_action_at_least_once_with_filters(env, action)
215
- when at_most_once? && ack_every_n_messages <= 1 # Acknowledging every single message
175
+ when at_most_once?
216
176
  _run_action_at_most_once_with_filters(env, action)
217
- when at_most_once? && ack_every_n_messages > 1 # Acknowledging messages in offset groups (every 10 messages or whatever the offset is)
218
- _run_action_at_most_once_multiple_with_filters(env, action)
219
177
  else
220
178
  _run_action_with_filters(env, action)
221
179
  end
@@ -7,7 +7,6 @@ module ActionSubscriber
7
7
 
8
8
  attr_reader :action,
9
9
  :content_type,
10
- :delivery_tag,
11
10
  :encoded_payload,
12
11
  :exchange,
13
12
  :headers,
@@ -41,8 +40,9 @@ module ActionSubscriber
41
40
  @subscriber = subscriber
42
41
  end
43
42
 
44
- def acknowledge(acknowledge_multiple_messages = false)
43
+ def acknowledge
45
44
  fail ::RuntimeError, "you can't acknowledge messages under the polling API" unless @channel
45
+ acknowledge_multiple_messages = false
46
46
  @channel.ack(@delivery_tag, acknowledge_multiple_messages)
47
47
  true
48
48
  end
@@ -8,9 +8,11 @@ module ActionSubscriber
8
8
  end
9
9
 
10
10
  def call(env)
11
- logger.info "START #{env.message_id} #{env.subscriber}##{env.action}"
12
- env.subscriber.run_action_with_filters(env, env.action)
13
- logger.info "FINISHED #{env.message_id}"
11
+ logger.info { "START #{env.message_id} #{env.subscriber}##{env.action}" }
12
+ ::ActiveSupport::Notifications.instrument "process_event.action_subscriber", :subscriber => env.subscriber.to_s, :routing_key => env.routing_key, :queue => env.queue do
13
+ env.subscriber.run_action_with_filters(env, env.action)
14
+ end
15
+ logger.info { "FINISHED #{env.message_id}" }
14
16
  end
15
17
  end
16
18
  end
@@ -23,11 +23,6 @@ module ActionSubscriber
23
23
  logger.info " -- queue: #{route.queue}"
24
24
  logger.info " -- routing_key: #{route.routing_key}"
25
25
  logger.info " -- prefetch: #{route.prefetch}"
26
- if subscriber.at_most_once? && (route.prefetch < subscriber.ack_every_n_messages || subscriber.ack_every_n_messages <= 0)
27
- # https://www.rabbitmq.com/blog/2011/09/24/sizing-your-rabbits/
28
- logger.error "ERROR Subscriber has ack_every_n_messages as #{subscriber.ack_every_n_messages} and route has prefetch as #{route.prefetch}"
29
- fail "prefetch < ack_every_n_messages, deadlock will occur"
30
- end
31
26
  if route.acknowledgements != subscriber.acknowledge_messages?
32
27
  logger.error "WARNING subscriber has acknowledgements as #{subscriber.acknowledge_messages?} and route has acknowledgements as #{route.acknowledgements}"
33
28
  end
@@ -63,10 +58,8 @@ module ActionSubscriber
63
58
 
64
59
  def run_env(env, threadpool)
65
60
  logger.info "RECEIVED #{env.message_id} from #{env.queue}"
66
- ::ActiveSupport::Notifications.instrument "process_event.action_subscriber", :subscriber => env.subscriber.to_s, :routing_key => env.routing_key, :queue => env.queue do
67
- threadpool << lambda do
68
- ::ActionSubscriber.config.middleware.call(env)
69
- end
61
+ threadpool << lambda do
62
+ ::ActionSubscriber.config.middleware.call(env)
70
63
  end
71
64
  end
72
65
  end
@@ -1,3 +1,3 @@
1
1
  module ActionSubscriber
2
- VERSION = "5.0.3.pre1"
2
+ VERSION = "5.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_subscriber
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.3.pre1
4
+ version: 5.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Stien
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2017-12-11 00:00:00.000000000 Z
15
+ date: 2017-12-18 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activesupport
@@ -278,9 +278,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
278
278
  version: '0'
279
279
  required_rubygems_version: !ruby/object:Gem::Requirement
280
280
  requirements:
281
- - - ">"
281
+ - - ">="
282
282
  - !ruby/object:Gem::Version
283
- version: 1.3.1
283
+ version: '0'
284
284
  requirements: []
285
285
  rubyforge_project:
286
286
  rubygems_version: 2.6.13