iColdCat
V2EX  ›  Java

请教个关于 dubbo 和 aop 的问题

  •  
  •   iColdCat · Dec 17, 2020 · 2431 views
    This topic created in 1982 days ago, the information mentioned may be changed or developed.

    想问一下各位 v 友,springboot 有没有什么办法在调用其他服务的 dubbo 接口的时候通过 aop 这种技术来做一个拦截? 现在的场景是我这一个项目,里边好多地方调了其他服务的 dubbo 接口,但是没有入参和出参的 log 打印,也都没做 try catch 处理,然后我想到了 aop,想通过 aop 做统一的出入参的日志打印和统一的 try catch 处理,但是 dubbo 接口是代理,并不归 springboot 管理 aop 切不到 那有没有什么好的工具能实现类似 aop 的这种功能呢 求各位赐教,感激不尽

    7 replies    2020-12-17 15:37:23 +08:00
    clf
        1
    clf  
       Dec 17, 2020
    dubbo 的统一的日志打印建议用专门的日志管理工具,进行调用链追踪。比如 Tlog 、zipkin 之类的。

    统一异常处理可以放在 dubbo 的 Filter 里。
    cheng6563
        2
    cheng6563  
       Dec 17, 2020
    不会 dubbo
    AOP 拦截不到的话,可以写一个 BeanPostProcessor,在 postProcessAfterInitialization 里用个代理 Bean 把原来的 Bean 替换掉。
    iColdCat
        3
    iColdCat  
    OP
       Dec 17, 2020
    @cheng6563 感谢,我去了解一下 BeanPostProcessor
    iColdCat
        4
    iColdCat  
    OP
       Dec 17, 2020
    @lychs1998 你说的 dubbo 的 Filter 是指服务提供方的 filter 吗
    yidinghe
        5
    yidinghe  
       Dec 17, 2020
    Dubbo 有提供内置的 Filter 机制,你若需要跟踪入参出参,写个 Filter 的实现类即可,无需学习 AOP 。具体自己搜索吧。
    hun2008hun
        6
    hun2008hun  
       Dec 17, 2020
    5 楼说的对,可以了解下 dubbo 的 SPI 机制
    iColdCat
        7
    iColdCat  
    OP
       Dec 17, 2020
    @yidinghe okok 我去了解下 谢啦
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1155 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 18:12 · PVG 02:12 · LAX 11:12 · JFK 14:12
    ♥ Do have faith in what you're doing.