Message received in a queue
Start a workflow when the consumer receives a message from the selected queue.
Workflow template
Keep one D1 journal entry per order event, even when the producer sends the event twice.
How it works
Start a workflow when the consumer receives a message from the selected queue.
Run a statement with bound values, or send a batch. Each row in the results uses the column names from your query.
Before activation
In your destination D1 database, run CREATE TABLE IF NOT EXISTS order_events (event_id TEXT NOT NULL PRIMARY KEY, payload TEXT NOT NULL). The primary key enforces one row per event even when deliveries overlap.
In the queue trigger, choose the account and enter the source queue name. Attach the FastHook relay as its consumer. In “Record the order event once”, select the D1 database that contains order_events.
Send a JSON object such as {"event_id":"order-1007-paid","order_id":"1007"}. Reuse that event_id when retrying payment confirmation. Give a later event, such as shipment, its own ID.
Activate the workflow and enqueue that same object twice. Check both workflow runs, then run SELECT COUNT(*) FROM order_events WHERE event_id = 'order-1007-paid'. The expected count is 1.