問(wèn)題描述
在使用Java 代碼向 Azure Event Hub發(fā)送數(shù)據(jù)時(shí),先后遇見(jiàn)了如下兩種異常消息:
**1)ERROR c.t.d.h.s.source.EventHubLogConsumer - Error occurred in partition processor for partition **
com.azure.core.amqp.exception.AmqpException: New receiver '********-****-****-****-************' with higher epoch of '0' is created hence current receiver 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' with epoch '0' is getting disconnected. If you are recreating the receiver, make sure a higher epoch is used
2) ERROR c.a.c.amqp.implementation.RetryUtil - partitionId[null]: Sending messages timed out
問(wèn)題解答
一:ERROR c.t.d.h.s.source.EventHubLogConsumer - Error occurred in partition processor for partition
New receiver '********-****-****-****-************' with higher epoch of '0' is created hence current receiver 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' with epoch '0' is getting disconnected
這個(gè)錯(cuò)誤表明當(dāng)前的客戶端已經(jīng)丟失了Event Hub的分區(qū)所有權(quán), 一個(gè)新的客戶端(receiver)搶占了當(dāng)前分區(qū)的所有權(quán),分區(qū)中的消息會(huì)繼續(xù)由新的客戶端消費(fèi)。所以當(dāng)前消費(fèi)端日志中出現(xiàn)這樣的錯(cuò)誤日志。
該錯(cuò)誤主要起一個(gè)提示作用,對(duì)Event Hub消費(fèi)數(shù)據(jù)無(wú)影響, 可以忽略。關(guān)于分區(qū)的所有權(quán)介紹,請(qǐng)參考:分區(qū)所有權(quán)(https://docs.azure.cn/zh-cn/event-hubs/event-processor-balance-partition-load#partition-ownership)
2) ERROR c.a.c.amqp.implementation.RetryUtil - partitionId[null]: Sending messages timed out
因?yàn)樵诎l(fā)送消息的代碼中,添加了自定義元數(shù)據(jù)。而因?yàn)樽远x元數(shù)據(jù)的值為null,所以引發(fā)了發(fā)送消息time out的問(wèn)題。
通過(guò)實(shí)驗(yàn),添加 properties.put("test",null); 消息發(fā)送時(shí),返回partitionId[null]: Sending messages timed out 異常。如下圖:

自定義元數(shù)據(jù)的實(shí)例代碼見(jiàn):向 Azure 事件中心中的事件添加自定義數(shù)據(jù):https://docs.azure.cn/zh-cn/event-hubs/add-custom-data-event#java
EventData firstEvent = new EventData("EventData Sample 1".getBytes(UTF_8));
firstEvent.getProperties().put("EventType", "com.microsoft.samples.hello-event");
firstEvent.getProperties().put("priority", 1);
firstEvent.getProperties().put("score", 9.0);
參考資料
分區(qū)所有權(quán) : https://docs.azure.cn/zh-cn/event-hubs/event-processor-balance-partition-load#partition-ownership
Azure 事件中心中的事件添加自定義數(shù)據(jù) :https://docs.azure.cn/zh-cn/event-hubs/add-custom-data-event#java
當(dāng)在復(fù)雜的環(huán)境中面臨問(wèn)題,格物之道需:濁而靜之徐清,安以動(dòng)之徐生。 云中,恰是如此!
分類: 【Azure 事件中心】
標(biāo)簽: Event Hub Java SDK, event.metadata["PartitionContext"]["PartitionId"], properties.put("test",null), Eventhub中發(fā)送數(shù)據(jù)異常