Change visibility timeout for an SQS message using ruby aws-sdk [ruby newbie]
-
11-12-2019 - |
Question
could someone help with an example how to change visibility timeout for an sqs message using ruby aws-sdk ?
here is the code that I've used for my tests using the method batch_change_message_visibility, but I get the error "undefined method 'batch_change_message_visibility'"
require 'rubygems'
require 'aws-sdk'
sqs = AWS::SQS.new(
:access_key_id => access_key,
:secret_access_key => access_secret)
queue = sqs.queues.named(queue_name)
messages = []
messages << { :message => message_handle, :visibility_timeout => 5 }
queue.batch_change_message_visibility(messages)
Any Idea? Any help would the very welcome :) Thanks
Solution
You have to use the splat operator when passing the messages array parameter to the batch_change_message_visibility method.
As shown in the docs here, you should write (note the * before the messages parameter):
messages = []
messages << { :message => 'handle1', :visibility_timeout => 5 }
messages << { :message => 'handle2', :visibility_timeout => 10 }
queue.batch_change_visibility(*messages)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow