12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/aws_sqs_moniter/aws/builder/queue_builder.rb', line 12
def build
@logger.info building_queue: @name
queue_url = @sqs.create_queue(queue_name: @name)[:queue_url]
queue_arn = @sqs.get_queue_attributes(
queue_url: queue_url,
attribute_names: ['QueueArn']).attributes['QueueArn']
queue_configuration = AwsSqsMoniter.configuration.get_queue(@name)
attributes = {
'DelaySeconds' => queue_configuration.delay_seconds.to_s,
'MessageRetentionPeriod' => queue_configuration.message_retention_period.to_s,
'VisibilityTimeout' => queue_configuration.visibility_timeout.to_s
}
if AwsSqsMoniter.configuration.sqs_protocol == 'sqs'
if queue_configuration.respond_to?(:redrive_policy)
policy = '{}'
policy = redrive_policy(
queue_configuration.redrive_policy.dead_letter_queue,
queue_configuration.redrive_policy.max_receive_count) if queue_configuration.redrive_policy.enabled
attributes.merge! 'RedrivePolicy' => policy
end
policy = queue_policy
attributes.merge! 'Policy' => policy
end
@sqs.set_queue_attributes queue_url: queue_url, attributes: attributes
end
|