Learn how to use Sequin to trigger a Temporal workflow when data changes in your database. Ensure consistency across services and build complex, transactionally-consistent workflows.
users
table you created in the previous step as the source table.temporal-worker
) and enter the following url:temporal-worker
endpoint you just created. As a last step, add the following path to the endpoint:http://localhost:3333/delete-user
temporal-webhook-sink
) and click “Save” to save the webhook sink.users
table and will deliver a webhook to http://localhost:3333/delete-user
whenever a user is deleted.sequin-cdc-to-temporal
with a basic Temporal worker project:
src/server.ts
file and installing the express package:
src/activities.ts
file with the following code:
cleanUpExternalSystems
activity simulates the cleanup of a user’s data in external systems by delaying for 1 second. The second sendDeletionConfirmation
activity simulates sending a confirmation email by delaying for 500 milliseconds.
src/workflows.ts
file with the following code:
userDeletedSignal
(that’ll be triggered by the webhook from Sequin). It then runs the two activities and completes. Importantly, the workflow also defines how to handle and retry failed activities - in this case, the workflow will retry the activities up to 5 times.
src/shared.ts
file, define a constant for the task queue name:
src/worker.ts
file, define the worker:
src/server.ts
file, define the server with the following code:
/delete-user
endpoint that Sequin will deliver the webhook to. When the endpoint is called, it triggers the Temporal workflow with a signalWithStart
call.
Sequin detects delete
Webhook received
signalWithStart
call:Temporal workflow starts
cleanUpExternalSystems
and sendDeletionConfirmation
activities:Temporal workflow completes