private Partition selectPartition(final Message message,
            Class clazz) throws TubeClientException {
        String topic = message.getTopic();
        StringBuilder sBuilder = new StringBuilder(512);
        Map<Integer, List<Partition>> brokerPartList =
                this.producerManager.getTopicPartition(topic);
        if (brokerPartList == null || brokerPartList.isEmpty()) {
            throw new TubeClientException(sBuilder.append("Null partition for topic: ")
                    .append(message.getTopic()).append(", please try later!").toString());
        }
        List<Partition> partList =
                this.brokerRcvQltyStats.getAllowedBrokerPartitions(brokerPartList);
        if (partList == null || partList.isEmpty()) {
            throw new TubeClientException(sBuilder.append("No available partition for topic: ")
                    .append(message.getTopic()).toString());
        }
        Partition partition =
                this.partitionRouter.getPartition(message, partList);
        if (partition == null) {
            throw new TubeClientException(new StringBuilder(512)
                    .append("Not found available partition for topic: ")
                    .append(message.getTopic()).toString());
        }
        if (rpcServiceFactory.isServiceEmpty()) {
            return partition;
        }
        BrokerInfo brokerInfo = partition.getBroker();
        int count = 0;
        while (count++ < partList.size()) {
            if (rpcServiceFactory.getOrCreateService(clazz, brokerInfo, rpcConfig) != null) {
                break;
            }
            partition = this.partitionRouter.getPartition(message, partList);
            brokerInfo = partition.getBroker();
        }
        return partition;
    }
Check if the given topic accept publish message.

@param topic topic name
@return if accept message
@throws TubeClientException
inlong-tubemq/tubemq-client/src/main/java/org/apache/inlong/tubemq/client/producer/SimpleMessageProducer.java