Running a Node consumer to pipe Genesys Cloud Notification events into Kafka. The WebSocket connection stays open, but I’m seeing significant gaps in the analytics data stream when call volume spikes. The SDK’s internal retry logic seems to handle disconnects, but I suspect the backpressure isn’t being managed correctly on the consumer side, causing events to queue up and drop before hitting my write callback.
Here’s the loop I’m using to process the stream:
const stream = apiInstance.notificationsApi.getStreamNotifications(
'analytics',
{
filter: 'event.type eq "conversation:analytics"',
subscriptionType: 'stream'
}
);
stream.on('data', (event: any) => {
kafkaProducer.send({
topic: 'gc-analytics-stream',
messages: [{ value: JSON.stringify(event) }]
});
});
The kafkaProducer is async, but I’m not awaiting the send call to keep the stream moving. Is there a better pattern to handle backpressure here without blocking the WebSocket read? Or should I be using the batch endpoint instead?