Azure / azure-event-hubs-node

Node client library for Azure Event Hubs https://azure.microsoft.com/services/event-hubs
MIT License
50 stars 46 forks source link

Initial offset for EventProcessorHost is set to 0 and cannot be overridden #185

Closed dpaje closed 5 years ago

dpaje commented 5 years ago

Describe the bug Initial offset for EventProcessorHost is set to 0 and cannot be overridden.

To Reproduce Steps to reproduce the behavior:

Expected behavior The initial offset should be overridable to whatever is passed to the create method. If it's not passed, it should correctly default to -1 (the eventhub default)

Package-name: azure-event-hubs | azure-event-processor-host Package-version: 1.0.6 node.js version: 9.7.1 OS name and version: OSX 10.14

Additional context Add any other context about the problem here.

AlexGhiondea commented 5 years ago

@dpaje thanks for raising this issue! Do you know what is the value that is returned by this code EventPosition.fromEnqueuedTime(Date.now()) ?

ShivangiReja commented 5 years ago

@dpaje I'm adding a sample code based on what you described above and It works without any errors.

I would like to suggest:

Sample Code:

async function startEph(ephName: string): Promise<EventProcessorHost> {
  // This is the enqueue time of my messages.
  const date: Date = new Date('Thu Feb 14 2019 12:14:20 GMT-0800 (Pacific Standard Time)');
  // Create the Event Processo Host
  const eph = EventProcessorHost.createFromConnectionString(
    EventProcessorHost.createHostName(ephName),
    storageCS!,
    storageContainerName,
    ehCS!,
    {
      eventHubPath: path,
      initialOffset: EventPosition.fromEnqueuedTime(date),
      onEphError: (error) => {
        console.log(">>>>>>> [%s] Error: %O", ephName, error);
      }
    }
  );

  const onMessage: OnReceivedMessage = async (context: PartitionContext, data: EventData) => {
    console.log(data);
   };
  // Error handler
  const onError: OnReceivedError = (error) => {
    console.log(">>>>> [%s] Received Error: %O", ephName, error);
  };
  console.log(">>>>>> Starting the EPH - %s", ephName);
  await eph.start(onMessage, onError);
  return eph;
}

Package-name: azure-event-processor-host Package-version: 1.0.6 node.js version: 10.14.1 OS name and version: Windows 10 Enterprise

Can you please provide more details about the error or stack trace?

ramya-rao-a commented 5 years ago

@dpaje We havent heard back from you in a while, so we are assuming that you are not seeing this issue anymore. Therefore, we are closing this issue.

If you still see this problem or you have any other feedback on this library, please feel free to open a new issue.