eventq_aws 0.3.4 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6471bdd6b18f30d44b11f4279793dc502d532464
4
- data.tar.gz: 5e68d6b2e6ab5d26de06a8b49aa4a087764febbd
3
+ metadata.gz: 7039aff7eed4a4842ed95ada249d8cc616b3efa5
4
+ data.tar.gz: 4b9bb9168911dc4ce3a21490a332181299101de5
5
5
  SHA512:
6
- metadata.gz: d8a11b3e593d6e6a034a77c1ea5cba7db35bef86ee642f78150dea6a0e5cef29c942bf1c5b0e943d303187268070d9356bfdf1781284cf2c853a66509226bba8
7
- data.tar.gz: 57fb26b969ba2371d58342a5e0baaf3d260a87b63bc651cd2927174289f8bf4f93fac390d984326123eefea0c80734aaed5cc191db9102a3fe7c489921c0eb50
6
+ metadata.gz: c4607ac871cfac8658cbb263cfbf3a943fc680cb0d87e4eb145a938195105f13dd285d548fc56a2844fa93be1e4fc5510ea3b638339d8840d1966de8568ab48a
7
+ data.tar.gz: 55d5ba87b7bc20acb29dc408cd0c3d2be134186750d66dc392ab99aa7a57177ecbef5debb023a92578d39a7e9940e5174ed720be4f09fed2f8a702aea64b5874
@@ -42,6 +42,14 @@ module EventQ
42
42
  return response.topic_arn
43
43
  end
44
44
 
45
+ def get_queue_url(queue)
46
+ response= @sqs.get_queue_url({
47
+ queue_name: aws_safe_name(queue.name),
48
+ queue_owner_aws_account_id: @aws_account,
49
+ })
50
+ return response.queue_url
51
+ end
52
+
45
53
  def aws_safe_name(name)
46
54
  name.gsub(':', '')
47
55
  end
@@ -15,6 +15,15 @@ module EventQ
15
15
 
16
16
  def get_queue(queue)
17
17
 
18
+ if queue_exists?(queue)
19
+ update_queue(queue)
20
+ else
21
+ create_queue(queue)
22
+ end
23
+
24
+ end
25
+
26
+ def create_queue(queue)
18
27
  response = @client.sqs.create_queue({
19
28
  queue_name: queue.name,
20
29
  attributes: {
@@ -23,7 +32,6 @@ module EventQ
23
32
  })
24
33
 
25
34
  return response.queue_url
26
-
27
35
  end
28
36
 
29
37
  def drop_queue(queue)
@@ -43,6 +51,21 @@ module EventQ
43
51
  return true
44
52
  end
45
53
 
54
+ def queue_exists?(queue)
55
+ return @client.sqs.list_queues({ queue_name_prefix: queue.name }).queue_urls.length > 0
56
+ end
57
+
58
+ def update_queue(queue)
59
+ url = @client.get_queue_url(queue)
60
+ @client.sqs.set_queue_attributes({
61
+ queue_url: url, # required
62
+ attributes: {
63
+ 'VisibilityTimeout' => (queue.retry_delay / 1000).to_s
64
+ }
65
+ })
66
+ return url
67
+ end
68
+
46
69
  end
47
70
  end
48
71
  end
@@ -149,6 +149,12 @@ module EventQ
149
149
  if !queue.allow_retry || retry_attempts >= queue.max_retry_attempts
150
150
  #remove the message from the queue so that it does not get retried again
151
151
  client.sqs.delete_message({ queue_url: q, receipt_handle: msg.receipt_handle })
152
+
153
+ if retry_attempts >= queue.max_retry_attempts && @retry_exceeded_block != nil
154
+ EventQ.logger.debug '[EVENTQ_AWS::QUEUE_WORKER] - Executing retry exceeded block.'
155
+ @retry_exceeded_block.call(message)
156
+ end
157
+
152
158
  end
153
159
  end
154
160
 
@@ -1,5 +1,5 @@
1
1
  module EventQ
2
2
  module Amazon
3
- VERSION = "0.3.4"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventq_aws
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - vaughanbrittonsage
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-11 00:00:00.000000000 Z
11
+ date: 2016-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler