无法在分区中设置检查点 [英] Unable to set checkpoint in partition
问题描述
我正在尝试使用此示例( https://docs.microsoft.com/zh-cn/azure/event-hubs/event-hubs-node-get-started-send ),但我无法读取未读数据只要.还有一件事,我得到两个不同的错误
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)连接ETIMEDOUT 40.112.242.0:5671
1) connect ETIMEDOUT 40.112.242.0:5671
2)更新检查点时租约丢失
2) lease lost while updating checkpoint
在node js示例中,我无法设置检查点.我也尝试过Azure/azure-sdk-for-js.但是它显示了上面列出的相同错误.
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.
当我也运行.netcore示例时,它们运行正常,所以我不明白为什么节点js示例运行不正常?
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?
推荐答案
对于node.js,请使用以下代码设置检查点,它对我而言效果很好:
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);
});
我可以看到在blob容器中检查点设置正确:
And I can see the checkpoint is set correctly in blob container:
这篇关于无法在分区中设置检查点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!