吴学文
2019-04-29 4ad9e7fb9477dddb3120e6ec71f0ab1e701ae36f
java110-event/src/main/java/com/java110/event/service/api/ServiceDataFlowEventPublishing.java
@@ -83,7 +83,8 @@
                dataFlowListeners.add(listener);
            }
            //特殊处理 透传类接口
            if(ServiceCodeConstant.SERVICE_CODE_DO_SERVICE_TRANSFER.equals(listener.getServiceCode())){
            if(ServiceCodeConstant.SERVICE_CODE_DO_SERVICE_TRANSFER.equals(listener.getServiceCode())
                    && ServiceCodeConstant.SERVICE_CODE_DO_SERVICE_TRANSFER.equals(serviceCode)){
                dataFlowListeners.add(listener);
            }
        }
@@ -141,15 +142,13 @@
     */
    public static void multicastEvent(String serviceCode,final ServiceDataFlowEvent event, String asyn) {
        String httpMethod = event.getDataFlowContext().getRequestCurrentHeaders().get(CommonConstant.HTTP_METHOD);
        for (final ServiceDataFlowListener listener : getListeners(serviceCode,httpMethod)) {
            //如果是透传类 请求方式必须与接口提供方调用方式一致
            if(ServiceCodeConstant.SERVICE_CODE_DO_SERVICE_TRANSFER.equals(serviceCode)){
                AppService appService = event.getAppService();
                if(!appService.getMethod().equals(httpMethod)) {
                    throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_ERROR,
                            "服务【" + serviceCode + "】调用方式不对请检查,当前请求方式为:"+httpMethod);
                }
            }
        List<ServiceDataFlowListener> listeners = getListeners(serviceCode,httpMethod);
        //这里判断 serviceCode + httpMethod 的侦听,如果没有注册直接报错。
        if(listeners == null || listeners.size() == 0){
            throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_ERROR,
                    "服务【" + serviceCode + "】调用方式【"+httpMethod+"】当前不支持");
        }
        for (final ServiceDataFlowListener listener : listeners) {
            if(CommonConstant.PROCESS_ORDER_ASYNCHRONOUS.equals(asyn)){ //异步处理