@Override
    public boolean connect2Partition(String partitionKey,
            long boostrapOffset,
            ProcessResult result) throws TubeClientException {
        if (result == null) {
            throw new TubeClientException("Illegal parameter: parameter result is null!");
        }
        final StringBuilder sBuffer = new StringBuilder(512);
        if (TStringUtils.isBlank(partitionKey)) {
            result.setFailResult(TErrCodeConstants.BAD_REQUEST,
                    "Parameter partitionKey is blank!");
            return result.isSuccess();
        }
        if (isShutdown()) {
            result.setFailResult(TErrCodeConstants.CLIENT_SHUTDOWN,
                    "The client is not started or closed!");
            return result.isSuccess();
        }
        if (clientRmtDataCache.isPartitionInUse(partitionKey)) {
            result.setSuccResult();
            return result.isSuccess();
        }
        if (!clientRmtDataCache.getSubscribablePartition(
                partitionKey, result, sBuffer)) {
            return result.isSuccess();
        }
        // check if high frequency request for failure partition
        Long lstTime = partRegFreqCtrlMap.get(partitionKey);
        if (lstTime != null
                && (System.currentTimeMillis() - lstTime < TClientConstants.CFG_MIN_META_QUERY_WAIT_PERIOD_MS)) {
            result.setFailResult(TErrCodeConstants.CLIENT_HIGH_FREQUENCY_REQUEST,
                    sBuffer.append("High-frequency request, please call ").append(partitionKey)
                            .append(" at least ").append(TClientConstants.CFG_MIN_META_QUERY_WAIT_PERIOD_MS)
                            .append("ms interval!").toString());
            sBuffer.delete(0, sBuffer.length());
            return result.isSuccess();
        }
        Partition partition = (Partition) result.getRetData();
        final String uniqueId =
                sBuffer.append(consumerConfig.getConsumerGroup())
                        .append("#").append(partitionKey).toString();
        sBuffer.delete(0, sBuffer.length());
        synchronized (uniqueId) {
            registerPartitions(partition, boostrapOffset, result, sBuffer);
        }
        if (!result.isSuccess()
                && (result.getErrCode() == TErrCodeConstants.PARTITION_OCCUPIED
                        || result.getErrCode() == TErrCodeConstants.CERTIFICATE_FAILURE)) {
            // only partition occupied or certificate failure need control frequency
            partRegFreqCtrlMap.put(partitionKey, System.currentTimeMillis());
        }
        return result.isSuccess();
    }
Initial a client-balance consumer object
@param messageSessionFactory   the session factory
@param consumerConfig          the consumer configure
@throws TubeClientException    the exception while creating object.
inlong-tubemq/tubemq-client/src/main/java/org/apache/inlong/tubemq/client/consumer/SimpleClientBalanceConsumer.java