Receive a message

from platonic.sqs.queue import SQSReceiver
from platonic.timeout import ConstantTimeout
from datetime import timedelta

incoming_numbers = SQSReceiver[int](
    # Thus we prevent the receiver from blocking forever if queue is empty

# If the queue is empty, this call with block until there is a message.
cmd = incoming_numbers.receive()
assert cmd.value == 15
# Do complicated stuff with the value
print(cmd.value * 1234 + 5767)


The message will appear again in the queue after visibility timeout expires, and you will receive it again, if you do not acknowledge the message after successful processing.

class platonic.sqs.queue.SQSReceiver(*args, **kwds)

Fetch one message from the queue.

If the queue is empty, by default block forever until a message arrives. See timeout argument of SQSReceiver class to see how to change that.

The id field of Message class is provided with ReceiptHandle property of the received message. This is a non-global identifier which is necessary to delete the message from the queue using self.acknowledge().