`
nepxion
  • 浏览: 37932 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

(十三) Nepxion-Thunder分布式RPC集成框架 - 事件发布

阅读更多

Nepxion-Thunder(QQ 群 471164539)发布在https://github.com/Nepxion/

 

基于Google Guava EventBus,实现事件驱动发布框架内部事件,解除耦合;发布外部事件,进行重试补偿,异常通知(邮件或短信通知)

 

1)eventbus - 基于Google Guava的进程内发布/订阅机制,支持同步和异步事件发布
2)mobile - 基于EventBus的异常信息的短信通知,未实现
3)protocol -
基于EventBus的异常信息的发布/拦截,是其它事件通知模块的基础
4)registry -
基于EventBus的上下线通知,通过Zookeeper的Watcher事件来发布
5)smtp - 基于EventBus的Smtp协议的邮件通知,
支持普通邮件和SSL认证邮件

1. 系统通知

邮件通知,一旦框架中有异常抛出,立即通过给定的邮件予以通知,

 

 

短信通知,未实现

 

2. 业务层面的异常事件拦截

ProtocolEventInterceptor可以拦截和通知如下的异常:

  •  业务系统中抛出的任何异常
  • 业务系统定义的超时异常(异步和同步,但不支持广播)
  • 框架的中间价宕机产生异常,目前只支持Netty
  • 框架服务治理产生异常,例如限流异常

业务系统只需要继承ProtocolEventInterceptor,实现onEvent方法,就可以捕获全部异常抛出

public class ServiceEventInterceptor extends ProtocolEventInterceptor {
    @Override
    protected void onEvent(ProtocolEvent event) {
        ApplicationType applicationType = event.getApplicationType();
        ActionType actionType = event.getActionType();
        ProtocolType protocolType = event.getProtocolType();
        ProtocolMessage protocolMessage = event.getProtocolMessage();
        System.out.println("--------------------收到异步事件通知--------------------");
        System.out.println("Application type=" + applicationType);
        System.out.println("Action type=" + actionType);
        System.out.println("Protocol type=" + protocolType);
        if (actionType != ActionType.SYSTEM) {
            System.out.println("Trace id=" + protocolMessage.getTraceId());
            System.out.println("Interface=" + protocolMessage.getInterface());
            System.out.println("Method=" + protocolMessage.getMethod());
            System.out.println("Parameter types=" + Arrays.asList(protocolMessage.getParameterTypes()));
            System.out.println("Parameters=" + Arrays.asList(protocolMessage.getParameters()));
        } else {
            System.out.println("From url=" + protocolMessage.getFromUrl());
            System.out.println("To url=" + protocolMessage.getToUrl());
        }
        System.out.println("Exception=" + ExceptionUtil.toExceptionString(protocolMessage.getException()));
        System.out.println("-------------------------------------------------------");
    }
}

 

框架接入比较简单,见下面的示例

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:thunder="http://www.nepxion.com/schema/thunder"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
           http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
           http://www.nepxion.com/schema/thunder http://www.nepxion.com/schema/thunder/thunder-1.0.xsd">
   
    .......
    
    <!-- 异常的EventBus事件发布拦截 -->
    <bean id="eventInterceptor" class="com.nepxion.thunder.service.ServiceEventInterceptor"/>
</beans>
  • 大小: 35.3 KB
  • 大小: 44.9 KB
  • 大小: 2.8 KB
分享到:
评论

相关推荐

    基于Java的Thunder分布式RPC框架设计源码

    Nepxion Thunder是一个基于Java的分布式RPC框架,集成了Netty、Hessian、Kafka、ActiveMQ、Tibco、Zookeeper、Redis、Spring Web MVC、Spring Boot和Docker等技术。它支持多协议、多组件和多序列化,为开发者提供了...

    协程式驱动框架Nepxion-Coroutine.zip

    Coroutine是基于Kilim/Promise JDeferred的协程式驱动框架,基于Apache Zookeeper的分布式规则存储和动态规则变更通知。 主要特性: 1. 基于微服务框架理念设计 2. 支持同步/异步调用 3. 支持串行/并行调用 4....

    Thunder::high_voltage: Nepxion Thunder is a distribution RPC framework based on Netty + Hessian + Kafka + ActiveMQ + Tibco + Zookeeper + Redis + Spring Web MVC + Spring Boot + Docker 多协议、多组件、多序列化的分布式RPC调用框架

    Nepxion Thunder是一款基于Netty + Hessian + Kafka + ActiveMQ + Tibco + Zookeeper(Curator Framework) + Redis + FST + Spring + Spring Web MVC + Spring Boot + Docker分布式RPC调用框架。架构思想主要是来自...

    yinheli/docker-thunder-xware:latest 镜像打包下载

    yinheli/docker-thunder-xware:latest 镜像打包下载 群晖 NAS DSM 系统,只要三步使用 Docker 安装迅雷远程下载

    Go-Thunder⚡️一个Go框架用于快速构建强大的graphql服务

    在压缩包"thunder-master"中,包含了Thunder框架的源码和其他相关资源。开发者可以通过查看源码,了解其内部实现原理,也可以直接使用它来快速搭建自己的GraphQL服务。在实际开发过程中,结合Go语言的标准库和第三方...

    wine-thunder_0.6-2_all.deb

    wine-thunder_0.6-2_all.deb用于在linux系统下,使用wine直接按装的迅雷软件,实现高速下载,在ubunut,fedora等linux版本中,实现直接点击安装

    开源项目-omeid-thunder.zip

    "thunder-master"这个压缩包子文件名可能代表项目的主分支或主代码库,这在Git等版本控制系统中很常见,"master"通常指的是默认分支,存放着项目的最新稳定版本。解压后,用户可以访问到项目的源代码、文档、构建...

    Go-Thunder是BoltDB的交互式Shell

    Go-Thunder是一个基于BoltDB数据库的交互式Shell工具,主要设计用于方便地与BoltDB数据库进行交互,提供了一种命令行界面来操作和管理数据。BoltDB本身是Go语言实现的一个轻量级、文件存储的键值对数据库,它以其...

    A10-Thunder_1030S方案白皮书.pdf

    A10-Thunder_1030S方案白皮书.pdf

    home-work-thunder

    【压缩包子文件的文件名称列表】"thunder-oms" 这个文件名可能代表“Thunder Operation Management System”(迅雷运营管理系统),或者是一种特定的模块或服务。它可能包含了项目的源代码、配置文件、测试脚本等,...

    系统工具-文件下载-thunder_3.4.0.4338.zip

    标题中的“系统工具-文件下载-thunder_3.4.0.4338.zip”表明这是一款系统工具,具体来说是与文件下载相关的。这里的“thunder”很可能指的是迅雷,一个在中国广为人知的下载管理软件。版本号“3.4.0.4338”指示这是...

    A10-Thunder_6430S方案白皮书.pdf

    A10-Thunder_6430S方案白皮书.pdf

    开源项目-muesli-thunder.zip

    在使用Thunder时,用户应首先下载并解压“muesli-thunder.zip”文件,得到“thunder-master”目录。然后按照项目提供的安装指南编译并安装Thunder,最后通过命令行启动Thunder,开始探索和操作BoltDB数据库。对于...

    A10-Thunder_930方案白皮书.pdf

    A10 Thunder 930方案白皮书 A10 Thunder 930是A10 Networks公司推出的统一应用服务网关(UASG),采用64位系统、1U硬件,提供了极具性价比的解决方案。该设备基于A10极具扩展性的灵活高级核心操作系统(ACOS)架构...

    3D-Thunder-Lightning.zip

    3D-Thunder-Lightning.zip,受航母指令启发的开源未来动作飞行模拟器游戏,3D建模使用专门的软件来创建物理对象的数字模型。它是3D计算机图形的一个方面,用于视频游戏,3D打印和VR,以及其他应用程序。

    系统工具-文件下载-Thunderbird91.0b4.zip

    Thunderbird是一款由Mozilla基金会开发的开源邮件客户端,它集成了电子邮件、新闻组、RSS阅读器和日历功能,为用户提供了一站式的通信解决方案。Thunderbird91.0b4是该软件的一个版本,其中“91.0b4”表示的是版本号...

    A10-Thunder-5430S方案白皮书

    文档可能还涵盖了设备的硬件规格、性能指标、管理和监控工具,以及与其他A10产品或第三方系统的集成方法。 通过阅读这份白皮书,IT专业人员可以深入了解如何利用Thunder 5430S来构建和维护高性能、高可用性的数据...

    Android代码-Thunder

    Thunder Android OkHttp util package let response callback at MainThread(UIThread), also it‘s lifecycle safety. ⚠️ Thunder‘s code is based on SugarTask(Very nice code

    Thunder-Download-Extension-for-Chrome_v3.1等.zip

    【Thunder-Download-Extension-for-Chrome_v3.1等.zip】这个压缩包文件包含的是针对谷歌浏览器(Chrome)的迅雷下载扩展程序的版本v3.1。迅雷下载工具是一款在中国广泛使用的下载管理器,它以其高速下载能力和对各种...

    A10-Thunder_5430S方案白皮书.pdf

    A10 Thunder 5430S是一款专为高效能应用交付而设计的1U设备,集成了一系列先进的云服务解决方案,旨在提供统一的应用服务网关功能。这款设备的核心是A10的高级核心操作系统(ACOS),具备高度可扩展性和灵活性。通过...

Global site tag (gtag.js) - Google Analytics