{"record":{"id":"d5be2221ec405367","repo":"alibaba/canal","slug":"start-rabbitmq-producer-error-d5be22","errorCode":null,"errorMessage":"Start RabbitMQ producer error","messagePattern":"Start RabbitMQ producer error","errorType":"exception","errorClass":"CanalException","httpStatus":null,"severity":"error","filePath":"connector/rabbitmq-connector/src/main/java/com/alibaba/otter/canal/connector/rabbitmq/producer/CanalRabbitMQProducer.java","lineNumber":98,"sourceCode":"        }\n        factory.setVirtualHost(rabbitMQProperties.getVirtualHost());\n        try {\n            connect = factory.newConnection();\n            channel = connect.createChannel();\n            String queue = rabbitMQProperties.getQueue();\n            String exchange = rabbitMQProperties.getExchange();\n            String deliveryMode = rabbitMQProperties.getDeliveryMode();\n            String routingKey = rabbitMQProperties.getRoutingKey();\n            if (!StringUtils.isEmpty(queue)) {\n                channel.queueDeclare(queue, true, false, false, null);\n            }\n            if (!StringUtils.isEmpty(queue) && !StringUtils.isEmpty(exchange) && !StringUtils.isEmpty(deliveryMode)\n                && !StringUtils.isEmpty(routingKey)) {\n                channel.exchangeDeclare(exchange, deliveryMode, true, false, false, null);\n                channel.queueBind(queue, exchange, routingKey);\n            }\n        } catch (IOException | TimeoutException ex) {\n            throw new CanalException(\"Start RabbitMQ producer error\", ex);\n        }\n    }\n\n    private void loadRabbitMQProperties(Properties properties) {\n        RabbitMQProducerConfig rabbitMQProperties = (RabbitMQProducerConfig) this.mqProperties;\n        // 兼容下<=1.1.4的mq配置\n        doMoreCompatibleConvert(\"canal.mq.servers\", \"rabbitmq.host\", properties);\n\n        String host = PropertiesUtils.getProperty(properties, RabbitMQConstants.RABBITMQ_HOST);\n        if (!StringUtils.isEmpty(host)) {\n            rabbitMQProperties.setHost(host);\n        }\n        String vhost = PropertiesUtils.getProperty(properties, RabbitMQConstants.RABBITMQ_VIRTUAL_HOST);\n        if (!StringUtils.isEmpty(vhost)) {\n            rabbitMQProperties.setVirtualHost(vhost);\n        }\n        String exchange = PropertiesUtils.getProperty(properties, RabbitMQConstants.RABBITMQ_EXCHANGE);\n        if (!StringUtils.isEmpty(exchange)) {","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/alibaba/canal/blob/87be50e87686a3e8af08c368d0e1ffd1f59eb04a/connector/rabbitmq-connector/src/main/java/com/alibaba/otter/canal/connector/rabbitmq/producer/CanalRabbitMQProducer.java#L80-L116","documentation":"Thrown by CanalRabbitMQProducer.init when establishing the connection/channel and declaring the queue/exchange/binding raises IOException or TimeoutException. The producer could not fully initialize against the broker — connection refused, auth failure, or a queue/exchange declaration that conflicted with an existing one.","triggerScenarios":"newConnection/createChannel or channel.queueDeclare/exchangeDeclare/queueBind (lines ~88-96) throw IOException/TimeoutException. Causes: broker unreachable; credentials/vhost wrong; declaring a queue/exchange with parameters that conflict with an existing one (e.g. durable mismatch); passive declaration of a non-existent exchange.","commonSituations":"Wrong rabbitmq.host/credentials; queue already exists with different durability/params; exchange deliveryMode typo; broker down during producer init; permission denied to declare resources.","solutions":["Verify broker reachability, credentials, and vhost for the producer.","Ensure queue/exchange declaration parameters match any pre-existing resources (durable, type) — RabbitMQ rejects conflicting redeclarions.","Confirm the deliveryMode/routingKey values are valid and the exchange type string is correct.","Retry init for transient broker outages."],"exampleFix":"// before\ntry {\n    ...\n    channel.queueDeclare(queue, true, false, false, null);\n    channel.exchangeDeclare(exchange, deliveryMode, true, false, false, null);\n} catch (IOException | TimeoutException ex) {\n    throw new CanalException(\"Start RabbitMQ producer error\", ex);\n}\n\n// after — surface the failing resource in the error\ntry {\n    channel.queueDeclare(queue, true, false, false, null);\n} catch (IOException ex) {\n    throw new CanalException(\"queueDeclare failed for \" + queue, ex);\n}","handlingStrategy":"retry","validationCode":"if (StringUtils.isEmpty(rabbitMQProperties.getHost()))\n    throw new IllegalStateException(\"rabbitmq host missing\");\nif (!StringUtils.isEmpty(queue) && !StringUtils.isEmpty(exchange)) {\n    // ensure deliveryMode is a valid exchange type (direct, topic, fanout, headers)\n}","typeGuard":null,"tryCatchPattern":"try {\n    channel.queueDeclare(queue, true, false, false, null);\n} catch (IOException ex) {\n    throw new CanalException(\"queueDeclare failed for \" + queue, ex);\n}","preventionTips":["Ensure queue/exchange declaration params match any pre-existing resources.","Verify broker reachability and credentials for the producer.","Use a valid exchange type for deliveryMode (direct/topic/fanout/headers)."],"tags":["rabbitmq","producer","network","canal-connector","initialization"],"backgroundTag":null,"analyzedSha":"87be50e87686a3e8af08c368d0e1ffd1f59eb04a","analyzedAt":"2026-08-14T04:30:11.918Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}