private void handleClientExceptions(final Throwable clientException) { if (clientException != null) { this.isPumpHealthy = false; if (TRACE_LOGGER.isWarnEnabled()) { TRACE_LOGGER.warn(String.format( "Receive pump for eventHub (%s), consumerGroup (%s), partition (%s) exiting after receive exception %s", this.eventHubName, this.consumerGroupName, this.receiver.getPartitionId(), clientException.toString())); } this.onReceiveHandler.onError(clientException); } }
@Override public Void apply(final Iterable<EventData> receivedEvents, final Throwable clientException) { ReceivePump.this.handleClientExceptions(clientException); try { // don't invoke user call back - if stop is already raised / pump is unhealthy if (ReceivePump.this.shouldContinue() && (receivedEvents != null || (receivedEvents == null && ReceivePump.this.invokeOnTimeout))) { ReceivePump.this.onReceiveHandler.onReceive(receivedEvents); } } catch (final Throwable userCodeError) { ReceivePump.this.handleUserCodeExceptions(userCodeError); } ReceivePump.this.schedulePump(); return null; } }
public void receiveAndProcess() { if (this.shouldContinue()) { this.receiver.receive(this.onReceiveHandler.getMaxEventCount()) .handleAsync(this.processAndReschedule, this.executor); } else { if (TRACE_LOGGER.isInfoEnabled()) { TRACE_LOGGER.info(String.format("Stopping receive pump for eventHub (%s), consumerGroup (%s), partition (%s) as %s", this.eventHubName, this.consumerGroupName, this.receiver.getPartitionId(), this.stopPumpRaised.get() ? "per the request." : "pump ran into errors.")); } this.stopPump.complete(null); } }
private void schedulePump() { try { this.executor.execute(this); } catch (final RejectedExecutionException rejectedException) { this.isPumpHealthy = false; if (TRACE_LOGGER.isWarnEnabled()) { TRACE_LOGGER.warn(String.format( "Receive pump for eventHub (%s), consumerGroup (%s), partition (%s) exiting with error: %s", this.eventHubName, this.consumerGroupName, ReceivePump.this.receiver.getPartitionId(), rejectedException.toString())); } this.onReceiveHandler.onError(rejectedException); } }
public void sendToHandlers(Map<SystemStreamPartition, PartitionReceiveHandler> handlers) { if (eventData == null) return; handlers.forEach((ssp, value) -> value.onReceive(eventData.get(ssp))); }
private void handleUserCodeExceptions(final Throwable userCodeException) { this.isPumpHealthy = false; if (TRACE_LOGGER.isErrorEnabled()) { TRACE_LOGGER.error( String.format("Receive pump for eventHub (%s), consumerGroup (%s), partition (%s) " + "exiting after user-code exception %s", this.eventHubName, this.consumerGroupName, this.receiver.getPartitionId(), userCodeException.toString())); } this.onReceiveHandler.onError(userCodeException); if (userCodeException instanceof InterruptedException) { if (TRACE_LOGGER.isInfoEnabled()) { TRACE_LOGGER.info(String.format("Interrupting receive pump for eventHub (%s), consumerGroup (%s), partition (%s)", this.eventHubName, this.consumerGroupName, this.receiver.getPartitionId())); } Thread.currentThread().interrupt(); } }
public void triggerError(Map<SystemStreamPartition, PartitionReceiveHandler> handlers, Throwable e) { handlers.forEach((ssp, value) -> value.onError(e)); }