Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publisher bottleneck #44

Open
lordent opened this issue Feb 18, 2024 · 1 comment
Open

Publisher bottleneck #44

lordent opened this issue Feb 18, 2024 · 1 comment

Comments

@lordent
Copy link

lordent commented Feb 18, 2024

published = self.published_class.objects.filter(

Such an implementation looks like a bottleneck

published = self.published_class.objects.filter(
    status=StatusChoice.SCHEDULE, expires_at__gte=timezone.now()
)
for message in published:
    try:
        attempts = self.producer.send(message)
    except ExceededSendAttemptsException as exc:
        logger.exception(exc)
        message.retry = exc.attempts
        message.status = StatusChoice.FAILED
        message.expires_at = timezone.now() + timedelta(15)
        self.stdout.write(f"Message no published with body:\n{message.body}")
    else:
        message.retry = attempts
        message.status = StatusChoice.SUCCEEDED
        self.stdout.write(f"Message published with body:\n{message.body}")
    finally:
        message.save()

because new messages can arrive faster than once a second

def _waiting():
    sleep(1)

while the solution does not allow itself to be scaled in any way; you cannot simply launch another Publisher, otherwise the message will be sent twice

@ricardochaves
Copy link
Member

Hi @lordent ,
We still don't have a fix date. Any collaboration is welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants