Unable to set checkpoint in partition

风流意气都作罢 提交于 2020-01-06 04:54:06

问题


I am trying to use this sample (https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-node-get-started-send) but I am not able to read unread data only. One more thing I am getting two different error

1) connect ETIMEDOUT 40.112.242.0:5671

2) lease lost while updating checkpoint

In the node js sample, I am not able to set checkpoints. I have tried Azure/azure-sdk-for-js as well. But it is showing the same error listed above.

When I have also run .netcore sample then they are working fine so I am not getting why node js sample is not working fine?

Can you please guide me on how can fix this issue to read-only unread and new data?


回答1:


For node.js, please use the code below to set checkpoint, it works well at my side:

const { EventProcessorHost, delay } = require("@azure/event-processor-host");

//your eventhub name
const path = "myeventhub"; 

//your azure storage connection string
const storageCS = "DefaultEndpointsProtocol=https;AccountName=xx;AccountKey=xx;EndpointSuffix=core.windows.net";

//your eventhub namespace connectionstring 
const ehCS = "Endpoint=sb://xxx.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=xxx"

//your blob storage container name
const storageContainerName = "test6";

async function main() {
  // Create the Event Processo Host
  const eph = EventProcessorHost.createFromConnectionString(
    EventProcessorHost.createHostName("my-host"),
    storageCS,
    storageContainerName,
    ehCS,
    {
      eventHubPath: path
    }

  );
  let count = 0;
  // Message event handler
  const onMessage = async (context/*PartitionContext*/, data /*EventData*/) => {
    console.log(">>>>> Rx message from '%s': '%s'", context.partitionId, data.body);
    count++;

    return await context.checkpoint();
  };
  // Error event handler
  const onError = (error) => {
    console.log(">>>>> Received Error: %O", error);
  };
  // start the EPH
  await eph.start(onMessage, onError);
  // After some time let' say 2 minutes
  await delay(120000);
  // This will stop the EPH.
  await eph.stop();
}

main().catch((err) => {
  console.log(err);
});

And I can see the checkpoint is set correctly in blob container:



来源:https://stackoverflow.com/questions/58518519/unable-to-set-checkpoint-in-partition

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!