{"record":{"id":"754a7debab3525af","repo":"apache/seatunnel","slug":"you-haven-t-enable-transaction-in-pulsar-client","errorCode":null,"errorMessage":"You haven't enable transaction in Pulsar client.","messagePattern":"You haven't enable transaction in Pulsar client\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-pulsar/src/main/java/org/apache/seatunnel/connectors/seatunnel/pulsar/config/PulsarConfigUtil.java","lineNumber":139,"sourceCode":"        } else {\n            throw new PulsarConnectorException(\n                    PulsarConnectorErrorCode.PULSAR_AUTHENTICATION_FAILED,\n                    \"Authentication parameters are required when using authentication plug-in.\");\n        }\n    }\n\n    /**\n     * get TransactionCoordinatorClient\n     *\n     * @param pulsarClient\n     * @return\n     */\n    public static TransactionCoordinatorClient getTcClient(PulsarClient pulsarClient) {\n        TransactionCoordinatorClient coordinatorClient =\n                ((PulsarClientImpl) pulsarClient).getTcClient();\n        // enabled transaction.\n        if (coordinatorClient == null) {\n            throw new IllegalArgumentException(\"You haven't enable transaction in Pulsar client.\");\n        }\n\n        return coordinatorClient;\n    }\n\n    /**\n     * create transaction\n     *\n     * @param pulsarClient\n     * @param timeout\n     * @return\n     * @throws PulsarClientException\n     * @throws InterruptedException\n     * @throws ExecutionException\n     */\n    public static Transaction getTransaction(PulsarClient pulsarClient, int timeout)\n            throws PulsarClientException, InterruptedException, ExecutionException {\n        Transaction transaction =","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-pulsar/src/main/java/org/apache/seatunnel/connectors/seatunnel/pulsar/config/PulsarConfigUtil.java#L121-L157","documentation":"getTcClient casts the PulsarClient to PulsarClientImpl and fetches its TransactionCoordinatorClient. If the client was built without transactions enabled, the coordinator client is null and an IllegalArgumentException is thrown. It signals that transactional features cannot be used because the client lacks a transaction coordinator.","triggerScenarios":"Calling PulsarConfigUtil.getTcClient(pulsarClient) on a client whose builder was not configured with enableTransaction(true); coordinatorClient comes back null.","commonSituations":"Using transactional Pulsar sink/semantics while the client factory omitted the transactions flag; upgrading code that newly requires transactions but reusing an old client construction path; broker-side transaction coordinator also disabled.","solutions":["Enable transactions when building the client: clientBuilder.enableTransaction(true).","Ensure transactions are enabled on the Pulsar broker (transactionCoordinatorEnabled=true).","If transactions are unnecessary, don't request a TC client; use non-transactional send paths instead."],"exampleFix":"// before\nPulsarClient client = PulsarClient.builder().serviceUrl(url).create();\nTransactionCoordinatorClient tc = PulsarConfigUtil.getTcClient(client);\n// after\nPulsarClient client = PulsarClient.builder().serviceUrl(url).enableTransaction(true).create();\nTransactionCoordinatorClient tc = PulsarConfigUtil.getTcClient(client);","handlingStrategy":"try-catch","validationCode":"if (!clientBuilderConf.getOrDefault(\"enableTransaction\", \"false\").equals(\"true\")) { throw new IllegalStateException(\"enable transaction before getTcClient\"); }","typeGuard":"if (client instanceof PulsarClientImpl impl && impl.getTcClient() != null) { use(impl.getTcClient()); } else { enableTransactionsAndRebuild(); }","tryCatchPattern":"try { tc = PulsarConfigUtil.getTcClient(client); } catch (IllegalArgumentException e) { LOG.error(\"Transactions disabled on Pulsar client: {}\", e.getMessage()); }","preventionTips":["Call enableTransaction(true) in the PulsarClient builder whenever transactions are used","Confirm broker config transactionCoordinatorEnabled=true","Centralize client creation so the transactions flag is not dropped","Use getTcClient only on clients explicitly built for transactional workloads"],"tags":["pulsar","transactions","configuration"],"backgroundTag":"feature-not-enabled","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}