Skip to content

How get message Visibility Timeout value in Lambda?

0

Hi! How can I get a message VisibilityTimeout value in Lambda (Node.js script) triggered by SQS? I need to change this value for staying the message in Queue for a longer period for next processing. Or how can I get the VisibilityTimeout value of the Queue itself programmatically? P.S. I'm deploying the stack via serverless-framework.

1 Answer
1
Accepted Answer

Usually you can get the message visibility timeout when you make a call to get_messages, however, when invoked with Lambda, the Lambda service makes the call to get_messages, and it seems it does not ask for this attribute.

You could make a call to get_queue_attributes to the get the defines visibility timeout on the queue, but remember that you can override this value for individual messages when your message producer sends the messages to the queue.

AWS
EXPERT
answered 4 years ago
EXPERT
reviewed 2 years ago
  • I am trying to get get_queue_attributes() but I keep receiving an error. My code is sqs = boto3.client('sqs') sqs_response = sqs.get_queue_attributes( QueueUrl: 'https://my_sqs_url.fifo', AttributeNames = ['ApproximateNumberOfMessages'] ) My error is Runtime.UserCodeSyntaxError and it's always on the first line within the parenthesis (in this case, the QueueUrl line. Any help would be appreciated.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.