Queue Polling Initialization¶
Queue Polling is when you just want to poll a queue and is not concerned with event driven approach.
To set this:
Preparation¶
Have an AWS SQS queue created for your application.
Have
QUEUE_POLLING
in yourINIESTA_INITIALIZATION_TYPE
settings.Have your
INIESTA_SQS_QUEUE_NAME
set to the name of your queue or have your queue name in the format ofINIESTA_SQS_QUEUE_NAME_TEMPLATE
.Have your redis connection details in
INIESTA_CACHES
.
Execution¶
On initialization the following happens:
Loads iniesta configs
Attaches necessary listeners
Then when run:
Initializes a
SQSClient
onapp.messi
.Starts Polling for messages.
Handlers¶
When receiving messages, unlike event polling, we need to set up a single default handler for queue polling.
@SQSClient.handler
def default_handler(message)
# do something
pass
Note
Like with event polling handlers, there is currently a know issue where if the module containing the handlers are not imported on start up the handlers do not get registered. For a quick fix import the module(s) where your Insanic app resides.
See Also¶
iniesta.sqs.client Reference
iniesta.sqs.message Reference