当前位置:网站首页>集群方法同步执行框架 Suona
集群方法同步执行框架 Suona
2022-07-01 02:18:00 【cocowwy点儿cn】
Suona
Suona
一个去中心化的集群方法同步执行框架
Git地址:戳我
说明
项目借鉴XXL-job源码,以及SpingCloud的服务注册,实现单节点方法被调用时唤醒集群其余节点的方法,以达到去中心化的广播效果
场景
情景一:比如在使用 caffine
/ hashMap
作为服务节点的内存缓存的时候,这是有缺点的,因为在集群内,如果需要进行缓存清理操作,是需要对每个节点进行缓存清理的
情景二:类似于情景一,需要该服务的集群每个节点都执行某方法
如果需要解决这种方案,就得 MQ
等中间件来实现广播的操作,那么如果中间件挂了,或者是不想那么麻烦来依靠外部的组件来进行怎么办呢?
那么,可以尝试使用 @Suona
,旨在能够让开发者在单一节点的方法被调用的时候,触发其他节点的同步进行调用,来模拟广播的操作,而开发者仅需要使用一个注解来标记这个方法,即可达到拆箱即用的效果
使用方式
你只需要这样使用它:
@Service
public class ServiceA {
@Suona
public void sayA() {
// do sth.
}
}
这样,当集群内任意节点的方法被调用时,其余节点也会同时进行调用
使用环境
TECHNOLOGY | ENV |
---|---|
JDK | 1.8+ |
SpringCloud | discovery |
注意
如果使用了权限框架或者是自定义了web拦截器的需要注意一下:
由于Suona集群通讯采用内嵌的web接口进行,所以需要对该web请求进行放行: /suona/call
稳定版
<dependency>
<groupId>cn.cocowwy</groupId>
<artifactId>suona</artifactId>
<version>1.0.0</version>
</dependency>
快照版本见下,发布最新的代码
<dependency>
<groupId>cn.cocowwy</groupId>
<artifactId>suona</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<repositories>
<repository>
<id>snapshots</id>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
边栏推荐
- Factory + strategy mode
- 聚焦绿色低碳,数据中心散热进入“智能冷却”新时代
- Fast understanding of forward proxy and reverse proxy
- House change for agricultural products? "Disguised" house purchase subsidy!
- VirtualBox 安装增强功能
- 现在开户有优惠吗?另外,手机开户安全么?
- 小程序云开发之--微信公众号文章采集篇
- 零基础自学SQL课程 | 窗口函数
- PMP是什麼?
- How to add a condition for an associated table in an SQL statement [null value required or not required]
猜你喜欢
随机推荐
Winodws 快速添加开机启动项
Opencv -- Notes
Pytorch - - Basic Reference North Deux élèves du secondaire peuvent comprendre [Rétropropagation et Gradient descendant]
URL和URI
(翻译)使用眉状文本提高标题点击率
项目管理是什么?
Is there any discount for opening an account now? In addition, is it safe to open a mobile account?
(translation) use eyebrow shaped text to improve Title click through rate
[2022] Jiangxi postgraduate mathematical modeling scheme and code
Leetcode interview question 17.10 Main elements
LabVIEW calculates the camera image sensor resolution and lens focal length
There is no future to be expected. It is just the last fantasy of a migrant worker before he dies
Calculate special bonus
先写API文档还是先写代码?
@The difference between configurationproperties and @value
LabVIEW计算相机图像传感器分辨率以及镜头焦距
AS400 大廠面試
5款主流智能音箱入门款测评:苹果小米华为天猫小度,谁的表现更胜一筹?
SWT/ANR问题--ANR/JE引发SWT
Static domain and static method