public void close() {
        int totalSenderCnt;
        long startTime = System.currentTimeMillis();
        logger.info("MsgSenderFactory({}) is closing", this.factoryNo);
        senderCacheLock.writeLock().lock();
        try {
            // release groupId mapped senders
            totalSenderCnt = releaseAllGroupIdSenders(groupIdSenderMap);
            // release clusterId mapped senders
            totalSenderCnt += releaseAllClusterIdSenders(clusterIdSenderMap);
        } finally {
            senderCacheLock.writeLock().unlock();
        }
        logger.info("MsgSenderFactory({}) closed, release {} inlong senders, cost {} ms",
                this.factoryNo, totalSenderCnt, System.currentTimeMillis() - startTime);
    }
Base Message Sender Factory

Used to manage the instance relationship of the sender factory.
Since both singleton and multiple instances involve the same relationship,
they are abstracted and maintained separately here.
inlong-sdk/dataproxy-sdk/src/main/java/org/apache/inlong/sdk/dataproxy/BaseMsgSenderFactory.java