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 your INIESTA_INITIALIZATION_TYPE settings.

  • Have your INIESTA_SQS_QUEUE_NAME set to the name of your queue or have your queue name in the format of INIESTA_SQS_QUEUE_NAME_TEMPLATE.

  • Have your redis connection details in INIESTA_CACHES.

Execution

On initialization the following happens:

  1. Loads iniesta configs

  2. Attaches necessary listeners

Then when run:

  1. Initializes a SQSClient on app.messi.

  2. 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