{"record":{"id":"21c29edc21e1e12c","repo":"alibaba/canal","slug":"failed-to-fetch-the-data-after-timeout-21c29e","errorCode":null,"errorMessage":"Failed to fetch the data after: ${timeout}","messagePattern":"Failed to fetch the data after: (.+?)","errorType":"exception","errorClass":"CanalClientException","httpStatus":null,"severity":"warning","filePath":"connector/rabbitmq-connector/src/main/java/com/alibaba/otter/canal/connector/rabbitmq/consumer/CanalRabbitMQConsumer.java","lineNumber":176,"sourceCode":"        boolean isSuccess = batchMessage.isSuccess();\n        return isCompleted && isSuccess;\n    }\n\n    @Override\n    public List<CommonMessage> getMessage(Long timeout, TimeUnit unit) {\n        try {\n            if (this.lastGetBatchMessage != null) {\n                throw new CanalClientException(\"mq get/ack not support concurrent & async ack\");\n            }\n\n            ConsumerBatchMessage<CommonMessage> batchMessage = messageBlockingQueue.poll(timeout, unit);\n            if (batchMessage != null) {\n                this.lastGetBatchMessage = batchMessage;\n                return batchMessage.getData();\n            }\n        } catch (InterruptedException ex) {\n            logger.warn(\"Get message timeout\", ex);\n            throw new CanalClientException(\"Failed to fetch the data after: \" + timeout);\n        }\n        return null;\n    }\n\n    @Override\n    public void rollback() {\n        try {\n            if (this.lastGetBatchMessage != null) {\n                this.lastGetBatchMessage.fail();\n            }\n        } finally {\n            this.lastGetBatchMessage = null;\n        }\n    }\n\n    @Override\n    public void ack() {\n        try {","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/alibaba/canal/blob/87be50e87686a3e8af08c368d0e1ffd1f59eb04a/connector/rabbitmq-connector/src/main/java/com/alibaba/otter/canal/connector/rabbitmq/consumer/CanalRabbitMQConsumer.java#L158-L194","documentation":"Thrown by CanalRabbitMQConsumer.getMessage when messageBlockingQueue.poll(timeout, unit) is interrupted (InterruptedException) while waiting for a batch. It is not a broker error — it means the consumer thread was signaled to stop (interrupt()) while blocked waiting for messages to arrive.","triggerScenarios":"poll(timeout, unit) at line 171 throws InterruptedException because Thread.interrupt() was invoked on the consuming thread — typical during application shutdown or executor shutdownNow().","commonSituations":"Container/scheduler shutting down the consumer thread; explicit thread.interrupt() during stop; Spring/executor shutdownNow() interrupting blocked tasks. The message is benign if it occurs during a controlled shutdown.","solutions":["If during shutdown, treat it as expected: log and exit cleanly, restoring the interrupt status with Thread.currentThread().interrupt().","If unexpected, find the caller invoking interrupt() on the consumer thread and avoid interrupting it mid-poll.","Increase the poll timeout if you want fewer wake-ups, but the interrupt itself is an external signal, not a timeout of the broker."],"exampleFix":"// before\n} catch (InterruptedException ex) {\n    logger.warn(\"Get message timeout\", ex);\n    throw new CanalClientException(\"Failed to fetch the data after: \" + timeout);\n}\n\n// after — distinguish interruption from a real timeout\n} catch (InterruptedException ex) {\n    logger.warn(\"Get message interrupted\", ex);\n    Thread.currentThread().interrupt(); // restore flag\n    throw new CanalClientException(\"Get message interrupted after: \" + timeout);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"} catch (InterruptedException ex) {\n    logger.warn(\"Get message interrupted\", ex);\n    Thread.currentThread().interrupt();\n    // during shutdown: return empty; otherwise rethrow\n    if (isShuttingDown()) return Collections.emptyList();\n    throw new CanalClientException(\"Get message interrupted after: \" + timeout);\n}","preventionTips":["Restore the interrupt flag after catching InterruptedException.","Treat interruption during shutdown as expected, not an error.","Do not interrupt the consumer thread mid-poll for non-shutdown reasons."],"tags":["rabbitmq","consumer","threading","canal-connector","interruption"],"backgroundTag":null,"analyzedSha":"87be50e87686a3e8af08c368d0e1ffd1f59eb04a","analyzedAt":"2026-08-14T04:30:11.918Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}