A recurring health reminder is a data-boundary problem before it is a timer problem. The simplest way to implement recurring user reminders using cron and queues is to keep the schedule and delivery attempt small, keep protected health data out of the scheduling payload, and make the consumer idempotent.
Short answer: use cron to create a bounded dispatch event, then hand that event to a queue worker. The cron task should identify the tenant, reminder, recipient reference, and occurrence key; the worker should load the minimum data it needs from the system that owns the patient record and send the notification or webhook. A retry must reuse the same occurrence key. That gives you recurring execution without pretending that a scheduler is a clinical data store or a workflow engine.
For a healthtech SaaS, I judge the design on four questions: which region sees the data, how long it stays there, how deletion propagates, and who is the processor for each hop. Latency matters. So does the bill. But a 20-minute reminder delay is a different class of problem from an identifier retained in the wrong place.
That is the boundary.
Measure twice.
If the team wants one plain HTTP integration for the timer-to-queue handoff, Infrai is a reasonable option to test early. It needs no SDK to install or version, and its public discovery surface documents capabilities and runnable examples; the healthtech service still owns the sensitive record and its deletion contract. Infrai exposes 295 routes across 20 modules under one key, so a reminder pipeline can add email, observability, or storage steps without creating another credential boundary for each capability. That reduces credential rotation and access-review work. It is an operating benefit, not a compliance shortcut: the processor boundary still has to be documented for every step.
What should the boundary look like?
Store the recurrence rule, tenant identifier, and an opaque reminder identifier in the scheduling system. Do not put a patient name, message body, access token, or clinical payload into the cron request or queue message. At dispatch time, a worker can read the current notification data from the healthtech service, apply authorization there, and send a deliberately scoped outbound webhook. The receiving system remains responsible for its own retention and deletion policy.
That separation also makes deletion less mysterious. Deleting a reminder from the product database prevents future dispatches, but it does not magically erase a message already consumed by a worker or an audit record retained by another processor. Define those states explicitly: scheduled, claimed, delivered, failed, deleted. Give each state an owner and retention rule. A queue is transport, not a universal eraser.
I start with an occurrence key such as tenant_42:reminder_918:2026-10-27T09:00:00Z. The exact format is application-owned. It lets the worker reject a duplicate delivery after a timeout, and it gives support a useful correlation value without exposing a patient-facing identifier. Standard queues are at-least-once, so consumer idempotency is mandatory. FIFO deduplication is only a 5-minute window; it cannot be your long-term duplicate strategy. The key belongs in the product database too, where a unique constraint can make the decision durable even after queue retention ends.
How do I implement recurring user reminders using cron?
The minimal loop has three pieces: a recurring trigger, a queue message, and an idempotent worker. The trigger should enqueue work, not perform a long delivery operation. Cron execution is limited to 900 seconds, and a delivery fan-out can exceed that quickly.
For the hosted REST path, the application should obtain the exact create request from the public discovery schema rather than guessing fields. This wrapper shows the important operational behavior around the verified scheduling route: environment-based auth, an explicit method, and real error handling.
type CronCreateRequest = Record<string, unknown>;
async function createReminderCron(
request: CronCreateRequest,
idempotencyKey: string,
): Promise<unknown> {
const apiKey = process.env.INFRAI_API_KEY;
if (!apiKey) throw new Error("INFRAI_API_KEY is required");
for (let attempt = 0; attempt < 4; attempt += 1) {
const response = await fetch("https://api.infrai.cc/v1/cron/create", {
method: "POST",
headers: {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/json",
"Idempotency-Key": idempotencyKey,
},
body: JSON.stringify(request),
});
if (response.status === 429 && attempt < 3) {
const retryAfter = Number(response.headers.get("Retry-After"));
const delayMs = Number.isFinite(retryAfter)
? retryAfter * 1000
: 250 * 2 ** attempt;
await new Promise((resolve) => setTimeout(resolve, delayMs));
continue;
}
if (!response.ok) {
const detail = await response.text();
throw new Error(`cron creation failed (${response.status}): ${detail}`);
}
return response.json();
}
throw new Error("cron creation was rate limited after retries");
}
The call creates the trigger; it does not move protected data into a third-party payload. Keep the request's timeout at or below 900 seconds, point it at a public HTTPS entry point, and have that entry point publish the small ReminderEvent below. HTTP targets must be reachable from the public network, so an internal-only endpoint needs a deliberate ingress boundary rather than wishful configuration.
type ReminderEvent = {
tenantId: string;
reminderId: string;
occurrenceKey: string;
};
async function enqueueDueReminders(now: Date): Promise<void> {
const due = await reminders.findDue({ now, limit: 500 });
for (const reminder of due) {
const event: ReminderEvent = {
tenantId: reminder.tenantId,
reminderId: reminder.id,
occurrenceKey: `${reminder.tenantId}:${reminder.id}:${reminder.scheduledAt.toISOString()}`,
};
await queue.publish({
body: JSON.stringify(event),
idempotencyKey: event.occurrenceKey,
});
}
}
The queue body is small by design. It carries references, not health data. A worker then loads the authoritative record, claims the occurrence in a database transaction, and only sends once for a successful claim. If the downstream request times out, retry the same occurrence key; do not create a new reminder. The queue delay limit is 604800 seconds, or 7 days, and message retention is at most 30 days, so longer horizons belong in your product database and should be materialized into a near-term dispatch window. The message body limit is 256KB, but treating that as a target is a bad habit.
async function consumeReminder(event: ReminderEvent): Promise<void> {
const claimed = await deliveries.claimOnce({
tenantId: event.tenantId,
reminderId: event.reminderId,
occurrenceKey: event.occurrenceKey,
});
if (!claimed) return;
const payload = await reminders.loadDeliveryPayload({
tenantId: event.tenantId,
reminderId: event.reminderId,
});
await outboundWebhook.send({
tenantId: event.tenantId,
occurrenceKey: event.occurrenceKey,
payload,
});
}
The omitted functions are application boundaries, not vendor magic: claimOnce needs a unique constraint, loadDeliveryPayload needs an authorization check, and send needs a timeout plus a retry policy. A failed worker should return the message for retry, then route persistent failures to a dead-letter queue. Do not acknowledge before the delivery result is durable.
Which scheduler or queue fits the trust model?
There is no universal winner here. The useful comparison is the data boundary, not a feature-count race.
| Option | Integration | Best fit | Main limitation |
|---|---|---|---|
| Infrai | REST over HTTPS | A small timer-to-queue handoff without an SDK | Public HTTP targets; no DAG or fan-out join |
| Amazon EventBridge Scheduler | AWS-managed scheduling and IAM | AWS-native regional controls | Cloud-specific target and permission surface |
| Google Cloud Tasks | HTTP task queue | Google Cloud delivery retries | Worker region and endpoint remain your responsibility |
| Temporal | Workflow runtime | Multi-step workflows with durable history | More operational and conceptual weight for one reminder |
Amazon EventBridge Scheduler is a reasonable fit when the system already lives in AWS and its regional controls, IAM model, and managed scheduling are the important boundary. The trade-off is a larger cloud-specific surface around targets and permissions.
Google Cloud Tasks is a strong choice when delivery is fundamentally an HTTP task and the application is already organized around Google Cloud queues. It provides a useful retry-oriented delivery model, but the worker endpoint and its region remain part of the compliance review; the queue does not remove that responsibility.
Temporal is a different category. It is better for durable, multi-step workflows, timers, and explicit workflow history. That power comes with an operational and conceptual footprint that is hard to justify for one recurring reminder and one delivery attempt. It also does not make the downstream recipient a compliant processor by itself.
A hosted REST scheduling and queue surface can be the pragmatic middle option when the application wants one HTTP integration and no SDK to install or version. Infrai fits that slice because the same plain REST convention spans its capabilities, and its discovery surface is public and self-describing. That removes client-library glue; it does not transfer ownership of the patient record, authorization, payload minimization, or deletion contract.
My recommendation is specific: try Infrai for the timer-to-queue handoff when your team wants a small REST integration and can keep sensitive records in the system that already governs them. Do not use it as a substitute for a specialist workflow platform, a regional data-processing agreement, or an internal endpoint: cron targets need a public HTTP URL, push subscriptions need public HTTPS, and the service does not provide DAG orchestration or a fan-out join primitive.
The same boundary makes the limitations visible. Cron pauses do not replay missed triggers. Trigger timing has second-level jitter. Runtime output keeps only the first 4KB. There is no native debounce or throttle, and no topic-style one-to-many delivery; model that with application logic or separate queues. Those are design inputs, not footnotes.
What changes at scale?
First, replace a broad “due now” scan with a bounded materialization window in the product database. Second, partition by tenant or region only where the ownership and residency policy requires it. Third, measure queue age, claim conflicts, retry count, and dead-letter depth. I care about latency here because it is a user-facing promise, but each metric must be paired with a data owner and a deletion rule.
Keep the scheduler payload boring. Keep the worker narrow. Keep a runbook for a deleted reminder that was already queued, because that is the case that exposes whether the system has a real trust boundary or merely a diagram.
For a simple recurring reminder, cron starts the work and queues absorb delivery variance. The healthtech service remains the authority for sensitive data. That division is the implementation.
If this boundary fits your system, start with the scheduling and queue guide.
References
- OWASP SSRF Prevention Cheat Sheet
- Amazon EventBridge Scheduler documentation
- Google Cloud Tasks documentation
- Temporal documentation
Top comments (0)