{"record":{"id":"18b52632122f760b","repo":"apache/seatunnel","slug":"failed-to-setup-rabbitmq-queue","errorCode":null,"errorMessage":"Failed to setup RabbitMQ queue","messagePattern":"Failed to setup RabbitMQ queue","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"critical","filePath":"seatunnel-connectors-v2/connector-rabbitmq/src/main/java/org/apache/seatunnel/connectors/seatunnel/rabbitmq/sink/RabbitmqSinkWriter.java","lineNumber":38,"sourceCode":"import org.apache.seatunnel.api.table.type.SeaTunnelRow;\nimport org.apache.seatunnel.api.table.type.SeaTunnelRowType;\nimport org.apache.seatunnel.connectors.seatunnel.common.sink.AbstractSinkWriter;\nimport org.apache.seatunnel.connectors.seatunnel.rabbitmq.client.RabbitmqClient;\nimport org.apache.seatunnel.connectors.seatunnel.rabbitmq.config.RabbitmqConfig;\nimport org.apache.seatunnel.format.json.JsonSerializationSchema;\n\nimport java.util.Optional;\n\npublic class RabbitmqSinkWriter extends AbstractSinkWriter<SeaTunnelRow, Void> {\n    private RabbitmqClient rabbitMQClient;\n    private final JsonSerializationSchema jsonSerializationSchema;\n\n    public RabbitmqSinkWriter(RabbitmqConfig config, SeaTunnelRowType seaTunnelRowType) {\n        this.rabbitMQClient = new RabbitmqClient(config);\n        try {\n            this.rabbitMQClient.setupQueue();\n        } catch (Exception e) {\n            throw new RuntimeException(\"Failed to setup RabbitMQ queue\", e);\n        }\n        this.jsonSerializationSchema = new JsonSerializationSchema(seaTunnelRowType);\n    }\n\n    @Override\n    public void write(SeaTunnelRow element) {\n        rabbitMQClient.write(jsonSerializationSchema.serialize(element));\n    }\n\n    @Override\n    public Optional prepareCommit() {\n        return Optional.empty();\n    }\n\n    @Override\n    public void close() {\n        if (rabbitMQClient != null) {\n            rabbitMQClient.close();","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-rabbitmq/src/main/java/org/apache/seatunnel/connectors/seatunnel/rabbitmq/sink/RabbitmqSinkWriter.java#L20-L56","documentation":"RabbitmqSinkWriter's constructor throws RuntimeException(\"Failed to setup RabbitMQ queue\") when RabbitmqClient.setupQueue() (queue declare/bind) throws any exception. Note this is a plain RuntimeException, not a SeaTunnel connector exception, and it aborts sink initialization.","triggerScenarios":"setupQueue() throws during sink writer construction — e.g. broker unreachable (ConnectException), access-refused for declare, channel already closed, or queue already exists with different parameters (406 PRECONDITION_FAILED).","commonSituations":"RabbitMQ not running or wrong host/port; user lacks configure permission to declare the queue; queue already exists with different durability/arguments causing an inequality error; vhost typo.","solutions":["Read the wrapped cause (`Caused by:`) to see the actual broker error, then fix connectivity, credentials, or permissions accordingly","Confirm queue/exchange declaration parameters match the existing queue (durable/auto-delete/arguments) — PRECONDITION_FAILED means an existing queue differs","Check the user's permissions with rabbitmqctl list_permissions for the vhost","Validate host/port/virtualHost in the sink config and test with a small standalone client"],"exampleFix":"// before (config mismatch causing 406 on declare)\nqueue-name = \"orders\"\ndurable = false // existing queue is durable\n// after\nqueue-name = \"orders\"\ndurable = true // matches existing declaration","handlingStrategy":"try-catch","validationCode":"// before the job: test declare on the target vhost\ntry (com.rabbitmq.client.Connection c = factory.newConnection();\n     com.rabbitmq.client.Channel ch = c.createChannel()) {\n  ch.queueDeclarePassive(\"orders\");\n  System.out.println(\"Queue reachable and permitted\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  client.setupQueue();\n} catch (Exception e) {\n  // inspect root cause: connectivity vs permission vs PRECONDITION_FAILED (queue args mismatch)\n  Throwable root = e;\n  while (root.getCause() != null) root = root.getCause();\n  throw new IllegalStateException(\"Queue setup failed: \" + root.getMessage(), e);\n}","preventionTips":["Check the `Caused by:` chain to distinguish network vs permissions vs queue-argument mismatch","Match durability/auto-delete/arguments with any pre-existing queue","Grant the configured RabbitMQ user configure permission on the vhost","Validate host/port/vhost in a smoke test before production runs"],"tags":["rabbitmq","queue-declare","initialization","sink"],"backgroundTag":"queue-declaration-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}