类 ResponseMessageProcessor


  • public class ResponseMessageProcessor
    extends Object
    消息处理器 Send message processor
    作者:
    tag 2019/2/25
    • 构造器详细资料

      • ResponseMessageProcessor

        public ResponseMessageProcessor()
    • 方法详细资料

      • handshake

        public static boolean handshake​(String url)
                                 throws Exception
        与已连接的模块握手 Shake hands with the core module (Manager)
        返回:
        boolean
        抛出:
        Exception - 握手失败, handshake failed
      • handshake

        public static boolean handshake​(io.netty.channel.Channel channel)
                                 throws Exception
        与已连接的模块握手 Shake hands with the core module (Manager)
        返回:
        boolean
        抛出:
        Exception - 握手失败, handshake failed
      • syncKernel

        public static void syncKernel​(String kernelUrl,
                                      BaseInvoke callbackInvoke)
                               throws Exception
        同步本地模块与核心模块(Manager) 1. 发送本地信息给Manager 2. 获取本地所依赖的角色的连接信息

        Synchronize Local Module and Core Module (Manager) 1. Send local information to Manager 2. Get connection information for locally dependent roles

        抛出:
        Exception - 核心模块(Manager)不可用,Core Module (Manager) Not Available
      • requestAndResponse

        public static Response requestAndResponse​(String role,
                                                  String cmd,
                                                  Map params)
                                           throws Exception
        发送Request,并等待Response Send Request and wait for Response
        参数:
        role - 远程方法所属的角色,The role of remote method
        cmd - 远程方法的命令,Command of the remote method
        params - 远程方法所需的参数,Parameters of the remote method
        返回:
        远程方法的返回结果,Response of the remote method
        抛出:
        Exception - 请求超时(1分钟),timeout (1 minute)
      • requestAndResponse

        public static Response requestAndResponse​(String role,
                                                  String cmd,
                                                  Map params,
                                                  long timeOut)
                                           throws Exception
        发送Request,并等待Response Send Request and wait for Response
        参数:
        role - 远程方法所属的角色,The role of remote method
        cmd - 远程方法的命令,Command of the remote method
        params - 远程方法所需的参数,Parameters of the remote method
        timeOut - 超时时间, timeout millis
        返回:
        远程方法的返回结果,Response of the remote method
        抛出:
        Exception - 请求超时(timeOut),timeout (timeOut)
      • requestAndInvoke

        public static String requestAndInvoke​(String role,
                                              String cmd,
                                              Map params,
                                              String subscriptionPeriod,
                                              String subscriptionEventCounter,
                                              BaseInvoke baseInvoke)
                                       throws Exception
        发送Request,并根据返回结果自动调用本地方法 Send the Request and automatically call the local method based on the return result
        参数:
        role - 远程方法所属的角色,The role of remote method
        cmd - 远程方法的命令,Command of the remote method
        params - 远程方法所需的参数,Parameters of the remote method
        subscriptionPeriod - 远程方法调用频率(秒),Frequency of remote method (Second)
        subscriptionEventCounter - 远程方法调用频率(改变次数),Frequency of remote method (Change count)
        baseInvoke - 响应该结果的类的实例,Classes that respond to this result
        返回:
        messageId,用以取消订阅 / messageId, used to unsubscribe
        抛出:
        Exception - 请求超时(1分钟),timeout (1 minute)
      • requestAndInvokeWithAck

        public static String requestAndInvokeWithAck​(String role,
                                                     String cmd,
                                                     Map params,
                                                     String subscriptionPeriod,
                                                     String subscriptionEventCounter,
                                                     BaseInvoke baseInvoke)
                                              throws Exception
        发送Request,需要一个Ack作为确认,并根据返回结果自动调用本地方法 Send the Request, an Ack must be received as an acknowledgement, and automatically call the local method based on the return result
        参数:
        role - 远程方法所属的角色,The role of remote method
        cmd - 远程方法的命令,Command of the remote method
        params - 远程方法所需的参数,Parameters of the remote method
        subscriptionPeriod - 远程方法调用频率(秒),Frequency of remote method (Second)
        subscriptionEventCounter - 远程方法调用频率(改变次数),Frequency of remote method (Change count)
        baseInvoke - 响应该结果的类的实例,Classes that respond to this result
        返回:
        messageId,用以取消订阅 / messageId, used to unsubscribe
        抛出:
        Exception - 请求超时(1分钟),timeout (1 minute)
      • requestAndInvoke

        public static String requestAndInvoke​(String role,
                                              Request request,
                                              BaseInvoke baseInvoke)
                                       throws Exception
        发送Request,封装Request对象(可以一次调用多个cmd) Send Request, need to wrap the Request object manually(for calling multiple methods at a time)
        参数:
        role - 远程方法所属的角色,The role of remote method
        request - 包含所有访问属性的Request对象,Request object containing all necessary information
        baseInvoke - 响应该结果的类的实例,Classes that respond to this result
        返回:
        messageId,用以取消订阅 / messageId, used to unsubscribe
        抛出:
        Exception - 请求超时(1分钟),timeout (1 minute)
      • requestOnly

        public static String requestOnly​(String role,
                                         Request request)
                                  throws Exception
        发送Request,不接收返回 Send Request and wait for Response
        参数:
        role - 远程方法所属的角色,The role of remote method
        request - 远程方法的命令,Command of the remote method
        返回:
        远程方法的返回结果,Response of the remote method
        抛出:
        Exception - 请求超时(1分钟),timeout (1 minute)
      • sendUnsubscribe

        public static void sendUnsubscribe​(String messageId)
                                    throws Exception
        取消订阅 Unsubscribe
        参数:
        messageId - 订阅时的messageId / MessageId when do subscription
        抛出:
        Exception - JSON格式转换错误、连接失败 / JSON format conversion error, connection failure