EnSync Engine Documentation Help

DEFER Command

Syntax

DEFER;CLIENT_ID=client_id;EVENT_IDEM=unique_id;EVENT_NAME=event_type;DELAY=milliseconds;PRIORITY=priority_level;REASON=deferral_reason

Parameters

Parameter

Description

Required

Example

CLIENT_ID

ID of the client deferring the event

Yes

client-123abc

EVENT_IDEM

Unique ID of the event to defer

Yes

evt_12345abcde

EVENT_NAME

Type of event being deferred

Yes

user/profile/updated

DELAY

Time in milliseconds to delay processing

No

60000

PRIORITY

Priority level (1-5, where 5 is highest)

No

5

REASON

Reason for deferring the event

No

Resource unavailable

If DELAY is not specified, it defaults to 60000 milliseconds (60 seconds).

If PRIORITY is not specified, it defaults to 1.

Response

Success

+PASS:DEFERRED;IDEM=evt_12345abcde;DELIVERY_TIME=1695420000000

The response includes:

  • IDEM: The ID of the deferred event

  • DELIVERY_TIME: The timestamp when the event will be delivered (in milliseconds since epoch)

Error

-FAIL:MISSING_PARAMETERS;MESSAGE=Missing required defer data. Ensure CLIENT_ID, EVENT_IDEM, and EVENT_NAME are passed
-FAIL:NOT_FOUND;MESSAGE=Event not found in processing queue

Examples

Basic Deferral

DEFER;CLIENT_ID=client-123abc;EVENT_IDEM=evt_12345abcde;EVENT_NAME=user/profile/updated;DELAY=60000;REASON=Resource unavailable

With Priority

DEFER;CLIENT_ID=client-123abc;EVENT_IDEM=evt_12345abcde;EVENT_NAME=user/profile/updated;DELAY=60000;PRIORITY=3;REASON=Resource unavailable

Short Retry

DEFER;CLIENT_ID=client-123abc;EVENT_IDEM=evt_12345abcde;EVENT_NAME=payment/process;DELAY=5000;REASON=Temporary service unavailable

Notes

  • Deferred events are stored with their delivery time as a score in a sorted set

  • When the delay period expires, events are automatically moved back to the pending queue

  • Events maintain their specified priority level throughout the deferral period

  • The system uses a background process to periodically check for events that are ready for delivery

  • Only the client that is currently processing an event can defer it

Last modified: 07 October 2025