how to make startAfterTime: [last closed time]
Closed this issue · 1 comments
willin commented
as #26 reported connection closed often.
and i have no idea about the err handling.
const createReceiver = async ({ connStr = '', partitionIds = [], errorHandler = defaultErrorHandler, messageHandler = defaultMessageHandler } = {}) => {
const client = EventHubClient.fromConnectionString(connStr);
await client.open();
partitionIds.forEach(async (partitionId) => {
// how to make startAfterTime to the time connection closed?
const receiver = await client.createReceiver('$Default', partitionId, { startAfterTime: Date.now() });
receiver.on('errorReceived', async (err) => {
// right?
if (err.transport && err.transport.name === 'AmqpProtocolError') {
console.log(`worker #${cluster.worker.id} PID:${process.pid} Restart #${partitionId}`);
// right?
await createReceiver({ connStr, partitionIds: [partitionId], errorHandler, messageHandler });
} else {
await errorHandler(err);
}
});
receiver.on('message', messageHandler);
});
};
i guess perhaps it may be related to checkpoint and storage,
like sample in dot net: https://github.com/Azure/azure-event-hubs/blob/master/samples/DotNet/Microsoft.Azure.EventHubs/SampleEphReceiver/SimpleEventProcessor.cs
amarzavery commented
We are working on an EPH implementation and there will be an implementation out shortly.