public static Object pbDecode(boolean isRequest, int methodId, byte[] bytes) throws Exception {
        // #lizard forgives
        // According to the method ID carried in the pb message, the corresponding class is directly used for mapping.
        if (isRequest) {
            switch (methodId) {
                case RpcConstants.RPC_MSG_MASTER_PRODUCER_REGISTER: {
                    return ClientMaster.RegisterRequestP2M.parseFrom(bytes);
                }
                case RpcConstants.RPC_MSG_MASTER_PRODUCER_HEARTBEAT: {
                    return ClientMaster.HeartRequestP2M.parseFrom(bytes);
                }
                case RpcConstants.RPC_MSG_MASTER_PRODUCER_CLOSECLIENT: {
                    return ClientMaster.CloseRequestP2M.parseFrom(bytes);
                }
                case RpcConstants.RPC_MSG_MASTER_CONSUMER_REGISTER: {
                    return ClientMaster.RegisterRequestC2M.parseFrom(bytes);
                }
                case RpcConstants.RPC_MSG_MASTER_CONSUMER_HEARTBEAT: {
                    return ClientMaster.HeartRequestC2M.parseFrom(bytes);
                }
                case RpcConstants.RPC_MSG_MASTER_CONSUMER_CLOSECLIENT: {
                    return ClientMaster.CloseRequestC2M.parseFrom(bytes);
                }
                case RpcConstants.RPC_MSG_MASTER_BROKER_REGISTER: {
                    return ClientMaster.RegisterRequestB2M.parseFrom(bytes);
                }
                case RpcConstants.RPC_MSG_MASTER_BROKER_HEARTBEAT: {
                    return ClientMaster.HeartRequestB2M.parseFrom(bytes);
                }
                case RpcConstants.RPC_MSG_MASTER_CONSUMER_REGISTER_V2: {
                    return ClientMaster.RegisterRequestC2MV2.parseFrom(bytes);
                }
                case RpcConstants.RPC_MSG_MASTER_CONSUMER_HEARTBEAT_V2: {
                    return ClientMaster.HeartRequestC2MV2.parseFrom(bytes);
                }
                case RpcConstants.RPC_MSG_MASTER_CONSUMER_GET_PART_META: {
                    return ClientMaster.GetPartMetaRequestC2M.parseFrom(bytes);
                }
                case RpcConstants.RPC_MSG_MASTER_BROKER_CLOSECLIENT: {
                    return ClientMaster.CloseRequestB2M.parseFrom(bytes);
                }
                case RpcConstants.RPC_MSG_BROKER_PRODUCER_SENDMESSAGE: {
                    return ClientBroker.SendMessageRequestP2B.parseFrom(bytes);
                }
                case RpcConstants.RPC_MSG_BROKER_CONSUMER_REGISTER: {
                    return ClientBroker.RegisterRequestC2B.parseFrom(bytes);
                }
                case RpcConstants.RPC_MSG_BROKER_CONSUMER_HEARTBEAT: {
                    return ClientBroker.HeartBeatRequestC2B.parseFrom(bytes);
                }
                case RpcConstants.RPC_MSG_BROKER_CONSUMER_GETMESSAGE: {
                    return ClientBroker.GetMessageRequestC2B.parseFrom(bytes);
                }
                case RpcConstants.RPC_MSG_BROKER_CONSUMER_COMMIT: {
                    return ClientBroker.CommitOffsetRequestC2B.parseFrom(bytes);
                }
                case RpcConstants.RPC_MSG_BROKER_CONSUMER_CLOSE:
                case RpcConstants.RPC_MSG_BROKER_PRODUCER_CLOSE:
                case RpcConstants.RPC_MSG_BROKER_PRODUCER_REGISTER:
                case RpcConstants.RPC_MSG_BROKER_PRODUCER_HEARTBEAT:
                default: {
                    throw new Exception(new StringBuilder(256)
                            .append("Unsupported method ID :")
                            .append(methodId).toString());
                }
            }
        } else {
            switch (methodId) {
                case RpcConstants.RPC_MSG_MASTER_PRODUCER_REGISTER: {
                    return ClientMaster.RegisterResponseM2P.parseFrom(bytes);
                }
                case RpcConstants.RPC_MSG_MASTER_PRODUCER_HEARTBEAT: {
                    return ClientMaster.HeartResponseM2P.parseFrom(bytes);
                }
                case RpcConstants.RPC_MSG_MASTER_PRODUCER_CLOSECLIENT: {
                    return ClientMaster.CloseResponseM2P.parseFrom(bytes);
                }
                case RpcConstants.RPC_MSG_MASTER_CONSUMER_REGISTER: {
                    return ClientMaster.RegisterResponseM2C.parseFrom(bytes);
                }
                case RpcConstants.RPC_MSG_MASTER_CONSUMER_HEARTBEAT: {
                    return ClientMaster.HeartResponseM2C.parseFrom(bytes);
                }
                case RpcConstants.RPC_MSG_MASTER_CONSUMER_CLOSECLIENT: {
                    return ClientMaster.CloseResponseM2C.parseFrom(bytes);
                }
                case RpcConstants.RPC_MSG_MASTER_BROKER_REGISTER: {
                    return ClientMaster.RegisterResponseM2B.parseFrom(bytes);
                }
                case RpcConstants.RPC_MSG_MASTER_BROKER_HEARTBEAT: {
                    return ClientMaster.HeartResponseM2B.parseFrom(bytes);
                }
                case RpcConstants.RPC_MSG_MASTER_BROKER_CLOSECLIENT: {
                    return ClientMaster.CloseResponseM2B.parseFrom(bytes);
                }
                case RpcConstants.RPC_MSG_MASTER_CONSUMER_REGISTER_V2: {
                    return ClientMaster.RegisterResponseM2CV2.parseFrom(bytes);
                }
                case RpcConstants.RPC_MSG_MASTER_CONSUMER_HEARTBEAT_V2: {
                    return ClientMaster.HeartResponseM2CV2.parseFrom(bytes);
                }
                case RpcConstants.RPC_MSG_MASTER_CONSUMER_GET_PART_META: {
                    return ClientMaster.GetPartMetaResponseM2C.parseFrom(bytes);
                }
                case RpcConstants.RPC_MSG_BROKER_PRODUCER_SENDMESSAGE: {
                    return ClientBroker.SendMessageResponseB2P.parseFrom(bytes);
                }
                case RpcConstants.RPC_MSG_BROKER_CONSUMER_REGISTER: {
                    return ClientBroker.RegisterResponseB2C.parseFrom(bytes);
                }
                case RpcConstants.RPC_MSG_BROKER_CONSUMER_HEARTBEAT: {
                    return ClientBroker.HeartBeatResponseB2C.parseFrom(bytes);
                }
                case RpcConstants.RPC_MSG_BROKER_CONSUMER_GETMESSAGE: {
                    return ClientBroker.GetMessageResponseB2C.parseFrom(bytes);
                }
                case RpcConstants.RPC_MSG_BROKER_CONSUMER_COMMIT: {
                    return ClientBroker.CommitOffsetResponseB2C.parseFrom(bytes);
                }
                case RpcConstants.RPC_MSG_BROKER_CONSUMER_CLOSE:
                case RpcConstants.RPC_MSG_BROKER_PRODUCER_CLOSE:
                case RpcConstants.RPC_MSG_BROKER_PRODUCER_REGISTER:
                case RpcConstants.RPC_MSG_BROKER_PRODUCER_HEARTBEAT:
                default: {
                    throw new Exception(new StringBuilder(256)
                            .append("Unsupported method ID :")
                            .append(methodId).toString());
                }
            }
        }
    }
Decode pb content

@param isRequest     whether a request message
@param methodId      the method id
@param bytes         the message content
@return              the message's object
@throws Exception    the exception while decoding messsage
inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corerpc/codec/PbEnDecoder.java