dubbo Filter
来源:互联网 发布:ubuntu 启动进入 grub> 编辑:程序博客网 时间:2024/05/30 05:24
对于Java Web应用,spring的拦截器可以拦截Web接口的调用,而对于dubbo接口,Spring的拦截器就不管用了。要实现此功能,需要dubbo提供Filter
dubbo中的Filter过滤器的使用场景:
1 、IP白名单
示例:给dubbo接口添加白名单——dubbo Filter的使用
http://blog.csdn.net/mj158518/article/details/47379799
2 、soa调用异常处理
import com.alibaba.dubbo.rpc.*;import com.#.service.channel.dto.response.ResponseResult;import com.##.service.channel.dto.response.ResponseResult.ResponseCode;import com.##.service.common.exception.BusinessException;import org.slf4j.Logger;import org.slf4j.LoggerFactory;public class EPayFilter implements Filter { private static final Logger LOGGER = LoggerFactory.getLogger(EPayFilter.class); @Override public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException { Result result = invoker.invoke(invocation); if (result.hasException()) { Throwable exception = result.getException(); if (exception instanceof BusinessException) { LOGGER.error("调用方法{}出现异常,请求参数为:{},异常信息为:{}", invocation.getMethodName(), invocation.getArguments(), exception.getMessage()); BusinessException e = (BusinessException) exception; ResponseResult responseResult = new ResponseResult(e.getResponseCode(), e.getMessage()); return new RpcResult(responseResult); } LOGGER.error("调用方法{}出现异常,请求参数为:{}", invocation.getMethodName(), invocation.getArguments(), exception); ResponseResult responseResult = new ResponseResult(ResponseCode.EXCEPTION, exception.getMessage()); return new RpcResult(responseResult); } return result; }}
配置参考白名单示例
0 0
- dubbo Filter
- dubbo中添加filter
- dubbo中的Filter顺序
- Dubbo源码分析(Filter)
- dubbo Filter源码分析
- dubbo学习笔记 十三 dubbo-filter
- Dubbo之——Dubbo Filter实战
- dubbo 5 Listener和Filter
- Dubbo源码分析 Handler & Filter
- dubbo 提示No such extension Filter for filter/com.alibaba.dubbo.rpc.Filter
- 10. Dubbo原理解析-Listener & filter
- dubbo 使用 filter 报错解决
- dubbo源码分析-consumer端5-Filter
- Dubbo源码分析(四)Handler & Filter
- dubbo关于filter组装,extension扩展逻辑.
- RpcMonitorFilter——monitor dubbo by filter
- dubbo 拦截器配置,Filter,ServletContextListener
- dubbo源码分析-consumer端5-Filter
- 《linux shell 脚本编程入门》读后记录
- Codeforces Round #395 (Div. 2) C. Timofey and a tree
- 密码学基础
- windows提示此Windows副本不是正版解决办法与工具
- SQL server使用笔记
- dubbo Filter
- 【codeforces 764C】Timofey and a tree
- CentOS Linux搭建SVN Server配置详解
- iOSApp上下有黑边
- Spring为什么Autowired注入的是接口
- PHP之RETURN用法
- [7]Linux进程控制
- Codeforces Round #395 (Div. 2) A B题 题解
- linux中netstat查看80端口连接数例子