You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can turn your Pub/Sub client application stateless by delegating the tracking of replay IDs to the server thanks to [managed event subscriptions](https://developer.salesforce.com/docs/platform/pub-sub-api/guide/managed-sub.html).
390
+
391
+
1. [Create a managed event subscription](https://developer.salesforce.com/docs/platform/pub-sub-api/guide/managed-sub.html#configuring-a-managed-event-subscription) using the tooling API. You can use API request templates from the [Salesforce Platform APIs](https://www.postman.com/salesforce-developers/salesforce-developers/folder/00bu8y3/managed-event-subscriptions) Postman collection to do so.
392
+
1. Subscribe to 3 events from a managed event subscription (`Managed_Sample_PE` in this expample):
393
+
```js
394
+
await client.subscribeWithManagedSubscription(
395
+
'Managed_Sample_PE',
396
+
subscribeCallback,
397
+
3
398
+
);
399
+
```
400
+
1. Using the subscription information sent in the subscribe callback, frequently commit the last replay ID that you receveive:
401
+
```js
402
+
client.commitReplayId(
403
+
subscription.subscriptionId,
404
+
subscription.lastReplayId
405
+
);
406
+
```
407
+
1. Optionnaly, request additional events to be sent (3 more in this example):
### Work with flow control for high volumes of events
387
413
388
414
When working with high volumes of events you can control the incoming flow of events by requesting a limited batch of events. This event flow control ensures that the client doesn’t get overwhelmed by accepting more events that it can handle if there is a spike in event publishing.
@@ -490,15 +516,26 @@ Builds a new Pub/Sub API client.
490
516
491
517
Closes the gRPC connection. The client will no longer receive events for any topic.
0 commit comments