Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

how to make startAfterTime: [last closed time] #28

Closed
willin opened this issue Jun 21, 2017 · 1 comment
Closed

how to make startAfterTime: [last closed time] #28

willin opened this issue Jun 21, 2017 · 1 comment

Comments

@willin
Copy link

willin commented Jun 21, 2017

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

https://blogs.msdn.microsoft.com/kaevans/2015/02/24/scaling-azure-event-hubs-processing-with-worker-roles/

and java: https://github.com/Azure/azure-event-hubs/blob/002a2056dda20fa79237fbc8bbdab3ef80065307/samples/Java/src/main/java/com/microsoft/azure/eventhubs/samples/Basic/EventProcessorSample.java

@amarzavery amarzavery changed the title hot to made startAfterTime: [last closed time] how to make startAfterTime: [last closed time] Apr 24, 2018
@amarzavery
Copy link
Collaborator

We are working on an EPH implementation and there will be an implementation out shortly.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants