問題描述
EventHub 中同一條消息,不停的推送給消費端,檢視日志發現錯誤:
Caused by: com.azure.messaging.eventhubs.implementation.PartitionProcessorException: Error in event processing callback
at com.azure.messaging.eventhubs.PartitionPumpManager.processEvent(PartitionPumpManager.java:280)
at com.azure.messaging.eventhubs.PartitionPumpManager.processEvents(PartitionPumpManager.java:314)
... 12 common frames omitted
Caused by: org.springframework.jdbc.BadSqlGrammarException:
### Error querying database. Cause: org.postgresql.util.PSQLException: ERROR: column "messageeventcode" does not exist
Hint: Perhaps you meant to reference the column "event_code".
Position: 2209
### The error may exist in file [D:\home\site\wwwroot\webapps\xxxxxx.xml]
### The error may involve defaultParameterMap
### The error occurred while setting parameters
問題分析
在用戶端的日志中,發現消費端每一分鐘都會與處理器(process event )建立,而消費端連接配接後,都會通過Storage Account上存儲的檢查點(Checkpoint)來開始消費消息,而發現檢查點一直都是同一個位置Starting event processing from offset[xxxx244317],随後就出現了 Exception: Error in event processing callback 異常,導緻消費端的這個程序關閉: Closing partition processor for partition 1 with close reason LOST_PARTITION_OWNERSHIP。
這個錯誤由接收事件時的錯誤或on_event中的錯誤引起,關閉了處理器連接配接,之後重建立立的連接配接還是從Starting event processing from offset[xxxx244317]開始的,是以導緻一直消費相同的資料。隻要解決了 PARTITION_PROCESSOR 事件中所引發異常的代碼後,就可以解決此問題。
參考資料
Event Hub CheckPoint: https://docs.azure.cn/zh-cn/event-hubs/event-hubs-features#checkpointing
當在複雜的環境中面臨問題,格物之道需:濁而靜之徐清,安以動之徐生。 雲中,恰是如此!