action_subscriber 1.7.0 → 2.0.0.pre0

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: 573c8a147dbac009a027ad0d10b404484fc8221f
4
- data.tar.gz: c137c197e7d3e047d836af47865ad41776e34ad6
3
+ metadata.gz: 598fa055880a3b6156840d9078febee5c3146777
4
+ data.tar.gz: f49e5bcef1fd6752084a2759472164cd2ff27c65
5
5
  SHA512:
6
- metadata.gz: 22868e675b4aeddcff1627423628be69c9db6562ce35bfefb7e1121b74756fbbd6132bc9246dd5b80d14f2a9e5bbf63e5c03793725833c741ef28e28375dad44
7
- data.tar.gz: 65b0a782d1791ba8a49a4f2c6a7e9ca2c6aefcdb026ac246dd607eb55d87dbdd05aae998df8393048e72953152f711429bc4af6816c0586a8ef159c7bef82ed3
6
+ metadata.gz: 66ceef1357703ca528f884e68486d0c8f8f40c956bebefdf2b6b520fb4603a4195f81c2d3006028d6f87637150540333f2769159ab8cd097a8d67ddec5fdd223
7
+ data.tar.gz: 7d5e4c2a4a7aa79bc92d7af7ef3c887fc7de9c445f669fcdca95b6fb41b88b961a6278441e9c5c5dee79e5dd523387ba238584bc59c32fe3121945777e48eefc
@@ -66,7 +66,7 @@ module ActionSubscriber
66
66
  def enqueue_env(threadpool, env)
67
67
  logger.info "RECEIVED #{env.message_id} from #{env.queue}"
68
68
  threadpool.async(env) do |env|
69
- ::ActiveSupport::Notifications.instrument "process_event.action_subscriber", :subscriber => env.subscriber.to_s, :routing_key => env.routing_key do
69
+ ::ActiveSupport::Notifications.instrument "process_event.action_subscriber", :subscriber => env.subscriber.to_s, :routing_key => env.routing_key, :queue => env.queue do
70
70
  ::ActionSubscriber.config.middleware.call(env)
71
71
  end
72
72
  end
@@ -67,7 +67,7 @@ module ActionSubscriber
67
67
  def enqueue_env(threadpool, env)
68
68
  logger.info "RECEIVED #{env.message_id} from #{env.queue}"
69
69
  threadpool.async(env) do |env|
70
- ::ActiveSupport::Notifications.instrument "process_event.action_subscriber", :subscriber => env.subscriber.to_s, :routing_key => env.routing_key do
70
+ ::ActiveSupport::Notifications.instrument "process_event.action_subscriber", :subscriber => env.subscriber.to_s, :routing_key => env.routing_key, :queue => env.queue do
71
71
  ::ActionSubscriber.config.middleware.call(env)
72
72
  end
73
73
  end
@@ -16,8 +16,9 @@ module ActionSubscriber
16
16
  next_attempt = get_last_attempt_number(env) + 1
17
17
  ttl = SCHEDULE[next_attempt]
18
18
  return unless ttl
19
- with_exchange(env, ttl) do |exchange|
20
- exchange.publish(env.encoded_payload, retry_options(env, next_attempt))
19
+ retry_queue_name = "#{env.queue}.retry_#{ttl}"
20
+ with_exchange(env, ttl, retry_queue_name) do |exchange|
21
+ exchange.publish(env.encoded_payload, retry_options(env, next_attempt, retry_queue_name))
21
22
  end
22
23
  end
23
24
 
@@ -30,26 +31,27 @@ module ActionSubscriber
30
31
  def self.retry_headers(env, attempt)
31
32
  env.headers.reject do |key, val|
32
33
  key == "x-death"
33
- end.merge({"as-attempt" => attempt.to_s})
34
+ end.merge({
35
+ "as-attempt" => attempt.to_s,
36
+ "x-dead-letter-routing-key" => env.queue,
37
+ })
34
38
  end
35
39
 
36
- def self.retry_options(env, attempt)
40
+ def self.retry_options(env, attempt, retry_queue_name)
37
41
  {
38
42
  :content_type => env.content_type,
39
- :routing_key => env.routing_key,
43
+ :routing_key => retry_queue_name,
40
44
  :headers => retry_headers(env, attempt),
41
45
  }
42
46
  end
43
47
 
44
- def self.with_exchange(env, ttl)
45
- exchange_retry_name = "#{env.exchange}_retry_#{ttl}"
46
- queue_retry_name = "#{env.queue}_retry_#{ttl}"
48
+ def self.with_exchange(env, ttl, retry_queue_name)
47
49
  channel = RabbitConnection.subscriber_connection.create_channel
48
50
  begin
49
51
  channel.confirm_select
50
- exchange = channel.topic(exchange_retry_name)
51
- queue = channel.queue(queue_retry_name, :arguments => {"x-dead-letter-exchange" => env.exchange, "x-message-ttl" => ttl})
52
- queue.bind(exchange, :routing_key => env.routing_key)
52
+ # an empty string is the default exchange [see bunny docs](http://rubybunny.info/articles/exchanges.html#default_exchange)
53
+ exchange = channel.topic("")
54
+ queue = channel.queue(retry_queue_name, :arguments => {"x-dead-letter-exchange" => "", "x-message-ttl" => ttl, "x-dead-letter-routing-key" => env.queue})
53
55
  yield(exchange)
54
56
  channel.wait_for_confirms
55
57
  ensure
@@ -1,3 +1,3 @@
1
1
  module ActionSubscriber
2
- VERSION = "1.7.0"
2
+ VERSION = "2.0.0.pre0"
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: 1.7.0
4
+ version: 2.0.0.pre0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Stien
@@ -265,9 +265,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
265
265
  version: '0'
266
266
  required_rubygems_version: !ruby/object:Gem::Requirement
267
267
  requirements:
268
- - - ">="
268
+ - - ">"
269
269
  - !ruby/object:Gem::Version
270
- version: '0'
270
+ version: 1.3.1
271
271
  requirements: []
272
272
  rubyforge_project:
273
273
  rubygems_version: 2.5.1