All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.taosdata.jdbc.tmq.OffsetWaitCallback Maven / Gradle / Ivy

There is a newer version: 3.4.0
Show newest version
package com.taosdata.jdbc.tmq;

import com.taosdata.jdbc.TSDBError;

import java.sql.SQLException;

import static com.taosdata.jdbc.TSDBConstants.TMQ_SUCCESS;

public class OffsetWaitCallback {
    private final ConsumerRecords cRecord;

    private final JNIConsumer consumer;
    private final OffsetCommitCallback callback;

    public OffsetWaitCallback(ConsumerRecords cRecord, JNIConsumer consumer, OffsetCommitCallback callback) {
        this.cRecord = cRecord;
        this.consumer = consumer;
        this.callback = callback;
    }

    @SuppressWarnings("unused")
    public void commitCallbackHandler(int code) throws SQLException {
        if (TMQ_SUCCESS != code) {
            Exception exception = TSDBError.createSQLException(code, consumer.getErrMsg(code));

            callback.onComplete(cRecord, exception);
        } else {
            callback.onComplete(cRecord, null);
        }

        consumer.closeOffset(cRecord.getOffset());
        consumer.releaseResultSet(cRecord.getOffset());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy