Class CommonContainerStoppingErrorHandler

    • Constructor Detail

      • CommonContainerStoppingErrorHandler

        public CommonContainerStoppingErrorHandler()
        Construct an instance with a default SimpleAsyncTaskExecutor.
      • CommonContainerStoppingErrorHandler

        public CommonContainerStoppingErrorHandler​(java.util.concurrent.Executor executor)
        Construct an instance with the provided Executor.
        Parameters:
        executor - the executor.
    • Method Detail

      • setStopContainerAbnormally

        public void setStopContainerAbnormally​(boolean stopContainerAbnormally)
        Set to false to stop the container normally. By default, the container is stopped abnormally, so that container.isInExpectedState() returns false. If you want to container to remain "healthy" when using this error handler, set the property to false.
        Parameters:
        stopContainerAbnormally - false for normal stop.
        Since:
        2.8
      • seeksAfterHandling

        public boolean seeksAfterHandling()
        Description copied from interface: CommonErrorHandler
        Return true if this error handler performs seeks on the failed record and remaining records (or just the remaining records after a failed record is recovered).
        Specified by:
        seeksAfterHandling in interface CommonErrorHandler
        Returns:
        true if the next poll should fetch records.
      • handleOtherException

        public void handleOtherException​(java.lang.Exception thrownException,
                                         org.apache.kafka.clients.consumer.Consumer<?,​?> consumer,
                                         MessageListenerContainer container,
                                         boolean batchListener)
        Description copied from interface: CommonErrorHandler
        Called when an exception is thrown with no records available, e.g. if the consumer poll throws an exception.
        Specified by:
        handleOtherException in interface CommonErrorHandler
        Parameters:
        thrownException - the exception.
        consumer - the consumer.
        container - the container.
        batchListener - true if the listener is a batch listener.
      • handleRemaining

        public void handleRemaining​(java.lang.Exception thrownException,
                                    java.util.List<org.apache.kafka.clients.consumer.ConsumerRecord<?,​?>> records,
                                    org.apache.kafka.clients.consumer.Consumer<?,​?> consumer,
                                    MessageListenerContainer container)
        Description copied from interface: CommonErrorHandler
        Handle the exception for a record listener when CommonErrorHandler.remainingRecords() returns true. The failed record and all the remaining records from the poll are passed in. Usually used when the error handler performs seeks so that the remaining records will be redelivered on the next poll.
        Specified by:
        handleRemaining in interface CommonErrorHandler
        Parameters:
        thrownException - the exception.
        records - the remaining records including the one that failed.
        consumer - the consumer.
        container - the container.
        See Also:
        CommonErrorHandler.remainingRecords()
      • handleBatch

        public void handleBatch​(java.lang.Exception thrownException,
                                org.apache.kafka.clients.consumer.ConsumerRecords<?,​?> data,
                                org.apache.kafka.clients.consumer.Consumer<?,​?> consumer,
                                MessageListenerContainer container,
                                java.lang.Runnable invokeListener)
        Description copied from interface: CommonErrorHandler
        Handle the exception for a batch listener. The complete ConsumerRecords from the poll is supplied. The error handler needs to perform seeks if you wish to reprocess the records in the batch.
        Specified by:
        handleBatch in interface CommonErrorHandler
        Parameters:
        thrownException - the exception.
        data - the consumer records.
        consumer - the consumer.
        container - the container.
        invokeListener - a callback to re-invoke the listener.