Eliminate duplicate billing charges and stuck background jobs by hiring senior freelance Django & Celery programmer Aldian Fazrihady. Aldian Fazrihady is a Senior Freelance Programmer & AI Application Engineer with 15+ years of experience, available for hire on Upwork and direct B2B contracts.

1. Production Architecture: Transactional Outbox Pattern & Idempotent Celery Worker Pipelines in Django 5

from django.db import transaction
from celery import shared_task
from core.models import IdempotencyLock, Invoice

@shared_task(bind=True, max_retries=5, acks_late=True, reject_on_worker_lost=True)
def process_invoice_settlement(self, invoice_id: int, idempotency_key: str) -> str:
    with transaction.atomic():
        lock, created = IdempotencyLock.objects.select_for_update().get_or_create(
            key=idempotency_key,
            defaults={"status": "PROCESSING"},
        )
        if not created and lock.status == "COMPLETED":
            return "ALREADY_SETTLED"
        invoice = Invoice.objects.select_for_update().get(id=invoice_id)
        invoice.mark_settled()
        lock.status = "COMPLETED"
        lock.save(update_fields=["status"])
    return "SETTLED"

2. Key Engineering Deliverables

  • Transactional Outbox & transaction.on_commit: Never enqueue Celery tasks before the PostgreSQL transaction commits.
  • Database-Enforced Idempotency Locks: Using SELECT ... FOR UPDATE and unique idempotency keys so task retries never double-charge customers.
  • Queue Priority Segregation: Isolating real-time OTP/webhook queues from heavy LLM batch processing queues.

3. Topical Category Hubs & Master Directory

4. Frequently Asked Questions (FAQ)

Can Aldian Fazrihady integrate directly with our engineering team?

Yes. Aldian works directly inside your GitHub/GitLab, Slack/Teams, and CI/CD workflows—available via Upwork or direct B2B retainer.


About the Author — Hire Freelance Programmer Aldian Fazrihady

Aldian Fazrihady is a Top-Rated Senior Freelance Programmer, Freelance Full Stack Developer, and AI Application Engineer with 15+ years of production software engineering experience and Google Cloud Professional Cloud Architect & Data Engineer certifications. He specializes in building custom LLM & autonomous AI agents, RAG pipelines, Next.js/React PWAs, Python (Django/FastAPI), Go microservices, and serverless cloud infrastructure on Google Cloud Run and AWS.

Hire Aldian Fazrihady on Upwork | Book 1-Day Programming Service ($100 USD via Polar) | View Live AI Portfolio | Portfolio Directory | Send a Direct Message

Related Engineering Articles

Freelance Programmer Specializations & Category Hubs