Data not being processed by Azure Event Hub Java client

百般思念 提交于 2019-12-23 02:16:07

问题


Following the EventProcessorHost example we implemented our custom logic in onEvents(). Some data is not being processed and I suspect this is because of the warnings thrown by the Java client.

In the log we see StorageException (time-out on blob storage for renewing leases or checkpointing), LeaseLostException (probably due to the previous exception) and EventHubException (when event hub move or go offline for a short period).

Basically my question is: How do these exceptions impact the processing of events and how can we make sure no events are skipped (e.g. via exception handling with retry and completely shutdown as last resort)?

I read through the docs and searched through other questions unable to find a satisfactory answer (this and this one provide some insight).

Our code:

public class EventProcessor implements IEventProcessor {
    ...
    @Override
    public void onEvents(PartitionContext context, Iterable<EventData> events) throws Exception {
        for (EventData event : events) {
            try {
                String message = new String(event.getBytes(), StandardCharsets.UTF_8);

                mystuff.process(message);

                this.checkpointBatchingCount++;
                if ((checkpointBatchingCount % 50) == 0) {
                    context.checkpoint(data).get();
                }
            } catch (Exception e) {
                LOG.warn("Processing event failed: {}", e.getMessage())
            }
        }
    }
    ...
}

来源:https://stackoverflow.com/questions/50953546/data-not-being-processed-by-azure-event-hub-java-client

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