MySQL and HTTP: Outbox Pattern Reliable Delivery Template

A Spojit template that drains a MySQL outbox table on a schedule, delivers each pending message to a REST API over the http connector, and marks a row sent only after the call succeeds.

What It Builds

A Schedule trigger fires on a cron interval and a Connector node on the mysql connector runs an execute-query to pull the next batch of pending rows from your outbox table. A Loop node walks each row, a Connector node on the http connector posts the payload to your target REST API with http-post, and only on a successful response does an update-rows call flip that row to sent. Rows that fail stay pending and are retried on the next scheduled run, so nothing is lost and nothing is double-delivered.

The Prompt

Paste this into Miraxa, the intelligent layer across your automation, and it builds the workflow and connects the tools for you:

Build a workflow that runs every 5 minutes on a schedule. Query my MySQL outbox table for up to 50 rows where status is 'pending', then loop over each row and POST its payload to https://api.example.com/v1/events with the http connector, sending my API key in the Authorization header. When the API returns a success status, update that row's status to 'sent' with a sent_at timestamp. If a call fails, leave the row as 'pending' so it retries on the next run.

Connectors Used

  • Schedule trigger - fires on a 5-field cron interval in your chosen timezone to drain the outbox.
  • mysql - execute-query reads pending rows and update-rows marks each one sent after delivery.
  • http - http-post delivers each row's payload to your external REST API.

Customize It

Change the cron interval in the prompt to match how fresh delivery needs to be, adjust the batch size (the 50 row limit) to control how much each run processes, and swap the endpoint URL and Authorization header to point at your own REST API. You can also rename the status values (pending / sent) to match your table, or add a failed status with a retry counter if you want to stop retrying a row after a set number of attempts.

Tips

  • Keep the http delivery node in Direct mode: the call is a single predictable http-post, so there is no need for Agent mode or AI credits.
  • Order your outbox query by the row's created timestamp so messages deliver in the sequence they were written.
  • Mark a row sent only inside the loop after the http response, never before, so a mid-run failure leaves the rest of the batch pending for the next scheduled run.

Related

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.