EnSync Engine Documentation Help

SUB Command

Syntax

SUB;CLIENT_ID=client_id;EVENT_NAME=event_type

Parameters

Parameter

Description

Required

Example

CLIENT_ID

ID of the client subscribing to events

Yes

client-123abc

EVENT_NAME

Type of event to subscribe to

Yes

user/profile/updated

Response

Success

+PASS:SUBSCRIBED;EVENT_NAME=user/profile/updated

The response confirms that the subscription was successful and includes the event name that was subscribed to.

Error

-FAIL:MISSING_PARAMETERS;MESSAGE=Missing required subscription request. Ensure CLIENT_ID, EVENT_NAME are passed
-FAIL:PERMISSION_DENIED;MESSAGE=Not authorized to subscribe to this event type
-FAIL:CLIENT_NOT_FOUND;MESSAGE=Invalid client ID

Examples

Basic Subscription

SUB;CLIENT_ID=client-123abc;EVENT_NAME=user/profile/updated

Domain-Level Subscription

Subscribe to all events in a domain:

SUB;CLIENT_ID=client-123abc;EVENT_NAME=order/*

Notes

  • Event names follow a hierarchical path-like structure (e.g., domain/resource/action)

  • Wildcards can be used to subscribe to multiple event types (e.g., order/* subscribes to all order events)

  • Clients can subscribe to multiple event types by sending multiple SUB commands

  • When a client subscribes to an event type, it will immediately begin receiving any new events of that type

  • The system will check if the client has the necessary permissions to subscribe to the requested event type

  • Multiple instances of the same service can subscribe to the same event types, implementing the competing consumer pattern

  • Each instance will receive a unique client ID to track its subscriptions and event processing state

Last modified: 07 October 2025