EnSync Engine Documentation Help

PUB Command

Syntax

PUB;CLIENT_ID=client_id;EVENT_NAME=event_type;PAYLOAD=json_data;DELIVERY_TO=recipient;METADATA=json_metadata

Parameters

Parameter

Description

Required

Example

CLIENT_ID

ID of the client sending the event

Yes

client-123abc

EVENT_NAME

Type of event being published

Yes

user/profile/updated

PAYLOAD

JSON data payload

Yes

{"id":"123","name":"John"}

DELIVERY_TO

Service ID of the recipient

Yes

service-456def

METADATA

Additional contextual information

No

{"source":"api"}

Response

Success

+PASS:PUBLISHED;IDEM=evt_12345abcde;TIMESTAMP=1695420000000

The response includes:

  • IDEM: A unique ID assigned to the event

  • TIMESTAMP: The time the event was published (in milliseconds since epoch)

Error

-FAIL:MISSING_PARAMETERS;MESSAGE=Missing required event data. Ensure CLIENT_ID, EVENT_NAME, PAYLOAD, DELIVERY_TO, and METADATA are passed
-FAIL:PERMISSION_DENIED;MESSAGE=Not authorized to publish this event type
-FAIL:CLIENT_NOT_FOUND;MESSAGE=Client not found

Examples

Basic Event Publishing

PUB;CLIENT_ID=client-123abc;EVENT_NAME=user/profile/updated;PAYLOAD={"id":"123","name":"John","email":"john@example.com"};DELIVERY_TO=user-service

Event with Metadata

PUB;CLIENT_ID=client-123abc;EVENT_NAME=order/created;PAYLOAD={"orderId":"ORD-123","items":[{"id":"ITEM-1","qty":2}]};DELIVERY_TO=order-service;METADATA={"source":"mobile-app","version":"2.1.0"}

Notes

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

  • Payload must be valid JSON

  • Events are stored in the persistent storage layer and cached for fast access

  • Events are delivered to all subscribers of the specified event type

  • The system verifies that the client has permission to publish the specified event type

  • Each event is assigned a unique IDEM for tracking and deduplication

Last modified: 07 October 2025