apache/seatunnel · warning · ActivemqConnectorException

CLOSE_CONNECTION_FAILED

CLOSE_CONNECTION_FAILED

Error message

Error while closing AMQ connection with  %s

What it means

ActivemqClient.close closes the underlying JMS connection; if connection.close() throws a JMSException it is wrapped as CLOSE_CONNECTION_FAILED. This happens during sink cleanup at the end of a task; it usually signals an already-broken connection rather than lost data.

Source

Thrown at seatunnel-connectors-v2/connector-activemq/src/main/java/org/apache/seatunnel/connectors/seatunnel/activemq/client/ActivemqClient.java:141

            producer.send(objectMessage);

        } catch (JMSException e) {
            throw new ActivemqConnectorException(
                    ActivemqConnectorErrorCode.SEND_MESSAGE_FAILED,
                    String.format(
                            "Cannot send AMQ message %s at %s",
                            config.get(QUEUE_NAME), config.get(CLIENT_ID)),
                    e);
        }
    }

    public void close() {
        try {
            if (connection != null) {
                connection.close();
            }
        } catch (JMSException e) {
            throw new ActivemqConnectorException(
                    ActivemqConnectorErrorCode.CLOSE_CONNECTION_FAILED,
                    String.format(
                            "Error while closing AMQ connection with  %s", config.get(QUEUE_NAME)));
        }
    }

    private Connection createConnection(ReadonlyConfig config) throws JMSException {
        if (config.get(USERNAME) != null && config.get(PASSWORD) != null) {
            return connectionFactory.createConnection(config.get(USERNAME), config.get(PASSWORD));
        }
        return connectionFactory.createConnection();
    }
}

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Check whether the broker was still up at job shutdown; fix underlying connectivity first
  2. Inspect the original exception logged before this error for the root cause
  3. Treat as secondary — if data was written successfully, this error mainly affects clean shutdown
  4. Upgrade connector version if close-on-dead-connection noise is recurring
Defensive patterns

Strategy: try-catch

Try / catch

try { writer.close(); } catch (ActivemqConnectorException e) { if (e.getErrorCode() == CLOSE_CONNECTION_FAILED) { log.warn("AMQ close failed; connection likely already dead", e); } }

Prevention

When it happens

Trigger: Calling close() when the JMS connection has already been dropped or the broker is unreachable, so connection.close() throws JMSException; config.get(QUEUE_NAME) is interpolated into the message.

Common situations: Broker went away before job teardown; network partition during job shutdown; close called twice after a prior failure invalidated the connection.

Understand the failure class

Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/629d13b22e62a8ff. Report an issue: GitHub.