question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support for arbitrary SQS message

See original GitHub issue

Hi. I came across this project because I am looking for a solution that will allow to run an execution pool (workers) that can process tasks from any AWS SQS queues with little effort. I mean queues that were not created by the application but are already present in AWS. These are e.g. various types of notifications from AWS systems, such as the creation of a file in S3. I tried Celery, but support for SQS in Celery comes down only to publishing and processing its own messages. I was hoping that pyqs would be able to process any message, but here the situation looks similar to Celery, we have:

def decode_message(message):
    message_body = message['Body']
    json_body = json.loads(message_body)
    if 'task' in message_body:
        return json_body
    # elif ... <<< here, or extract this part into its own method, like 'detect_message_type(message)'
    else:
        # Fallback to processing celery messages
        return decode_celery_message(json_body['body'])

Have you considered this possibility? This could work using the configuration option, or using a part of message that uniquely identifies Celery (such as, I think, “task” identifies pyqs in the code above).

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
spuleccommented, Sep 22, 2020

Yeah, that makes sense. I could imagine some type of more generic registry where we hook up task processors with queue names.

0reactions
januszmcommented, Aug 30, 2021

I think it’d also help to slightly change the current definition of the Manager Worker classes to avoid hardcoding the processor class name, which would make it easier, or possible at all to override, see:

def __init__(
  # ...
  self.process_worker = SimpleProcessWorker # allow override this after init

def _initialize_worker_children(self, number):
  ...
  self.worker_children.append(
-   SimpleProcessWorker(
+   self.process_worker(
Read more comments on GitHub >

github_iconTop Results From Across the Web

send-message — AWS CLI 1.27.33 Command Reference
The URL of the Amazon SQS queue to which a message is sent. ... Amazon SQS supports the following logical data types: String...
Read more >
Amazon SQS messages with arbitrary Python objects?
For an arbitrary Python object the answer is to serialize the object into a string, use SQS to send that string to the...
Read more >
send-message — AWS CLI 2.9.9 Command Reference
The URL of the Amazon SQS queue to which a message is sent. ... Amazon SQS supports the following logical data types: String...
Read more >
Working with AWS CLI SQS: Simplified 101 - Learn - Hevo Data
Amazon Simple Queue Service is a fully managed message queuing service for decoupling and scaling microservices, distributed systems, and ...
Read more >
aws sqs add-permission - Fig
For more information, see Using Custom Policies with the Amazon SQS Access Policy Language in the Amazon Simple Queue Service Developer Guide.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found