当前位置:网站首页>[untitled] how to realize pluggable configuration?
[untitled] how to realize pluggable configuration?
2022-07-26 00:32:00 【YYniannian】
Source code Gitee link :http://gitee.com/austin
01、 Pluggable
After my project gradually took shape , A lot of friends spit about my project Too heavy 了 , There are a few middleware dependencies .

In the first edition, you need Strong dependence MySQL/Redis/Kafka/Apollo( You need to deploy these middleware when the project starts ), Weak dependence
prometheus/graylog/flink/xxl-job( Want to have a complete project experience , We need to deploy these ).
- MySQL No one roast , Databases , It can be said that it is necessary for the back end .
- Redis No one has roast yet , After all, I still use too much , There are no strong competitors .
- Apollo Often roast whether it can be replaced by Nacos.
- Kafka Sometimes someone roast , Want to support RabbitMQ、RocketMQ.
I used to have an idea : Middleware is not easy to replace in the company , Now my code has implemented a posture , I don't think it's necessary to support multiple middleware implementations , If you want to change, just change it yourself , It's not hard .
「“Apollo Too heavy ,Apollo It fails to work well ! Support quickly Nacos!”」「“ Support RocketMQ How about ”」「“ Can you support RabbitMQ?”」
It's not a big reason for me , I still think Apollo Good use , Mature enough to be stable , Empathy Kafka The same is true . But when I was roast too much , Always doubt whether you are not doing well enough , I will also discuss with the bosses around me , Is it necessary to support some functions .
reasoning , I have changed , I get it again
In order to make the message push platform Austin Easy to use , I put it first Apollo Make weak dependence , Can be selected by configuration Read local files Or read the configuration center (Apollo). In fact, when we use Apollo when , Even if Apollo Hang up ,Apollo It has a strong disaster tolerance ability ( Bring your own local file )
secondly , I put Kafka Make weak dependence , Can be selected by configuration use Guava Of eventbus Or take the distributed message queue (Kafka), It may be supported later RocketMQ/RabbitMQ, Those who are interested can also implement one based on my code , Rub pull request Also very fragrant .
On the one hand is Lower the use threshold And do , On the other hand, the specific implementation can be Pluggable , This is a Open source project The required . I think if it is a company level production environment online project , More consideration is given to this Heterogeneous disaster recovery ( Not pluggable ).
So , Now the message push platform Austin The default strong dependency is only left MySQL and Redis, Other middleware are weak dependencies , To be pluggable, I am With the help of configuration To instantiate different middleware .
When my configuration austin-mq-pipeline=eventbus when , I won't instantiate Kafka Relevant producers and consumers , Instead, initialize eventBus The producers and consumers of , That's natural Implementation class under interface Is to eventbus Of


02、( Colored eggs )KAFKA Support TAG Filter
My shareholders can use my remote service directly :Kafka Of Topic Is Shared ,Group Consumers are also shared , Without modification , Direct use will bring a problem .
When two or more shareholders start up locally at the same time Austin, It will compete for consumption Topic( It is equivalent to having multiple consumers in a consumer group ), As a result, you may not receive your own debugging message when the test is issued ( Was robbed by other shareholders ).
My first thought to solve this problem is very simple : Different shareholders use different group( Equivalent to each shareholder will have an independent consumer group ), Then it's over ? Just my groupId Generation depends on channels code, Get rid of code It's over .

But there is still a problem : Each shareholder has an independent consumer group , It means that each shareholder can consume the whole topic All the news of , This in turn means that shareholders will receive the test information from other shareholders ( Obviously, I only want to test the news myself , But there was a message sent by someone else ).
To solve this problem , In addition to giving each shareholder an independent topic, That's it according to tag Filter La .
stay Kafka To achieve this effect , Pretty simple : At the time of sending , hold tag Write in Kafka The head of , Put yourself before consumption tag Filter out the message and it's over .


03、 summary
I've been iterating since I started writing this project , This process received a lot of roast . This kind of roast is mostly positive , After all, some people roast, that shows that my project is really used , Someone is watching .
I have an idea recently : Make this system online , Major developers can call my interface when pushing messages , It must be interesting to do this , There will also be more challenges and needs . Then I can always iterate , In this process, I will also learn a lot of things I didn't know before .
This time I use @ConditionAlOnProperties This annotation is used to realize pluggable configuration , But in fact, if it is in the form of a two-party Library , Use SPI The posture of Will be more elegant .
That's it today , Welcome to like 、 Leaving a message. .
Source code GitHub link :http://github.com/austin
边栏推荐
- 对“DOF: A Demand-oriented Framework for ImageDenoising“的理解
- 解决背景图设置100%铺满时,缩放浏览器出现水平滚动条时,滚动条超出的部分背景图没有铺满的问题
- Eight common SQL misuses of MySQL, all of which I have learned
- Tarjan 求强连通分量 O(n+m) ,缩点
- What are the precautions for using MySQL index? (answer from six aspects)
- IP核:PLL
- Redis killed twelve questions. How many questions can you carry?
- Redis命令参考手册 - Key
- 融合聚类信息的技术主题图可视化方法研究
- letfaw
猜你喜欢

The way of understanding JS: write a perfect combination inheritance (Es5)
![[redis] ③ data elimination strategy, pipeline command, publish and subscribe](/img/80/7caeb24380ea026aa8153f2169dfdd.png)
[redis] ③ data elimination strategy, pipeline command, publish and subscribe
![[calculate the number of times that one string is equal to another string]](/img/82/db8ed70464df46c7a700c65d208fef.png)
[calculate the number of times that one string is equal to another string]

Research on the integrated data quality management system and technical framework under the scenario of data circulation and transaction

【redis】③ 数据淘汰策略、pipeline 管道命令、发布订阅
![[paper notes] - target attitude estimation Epro PNP 2022 CVPR](/img/96/9d3887c897950c4acaa7a01eb08b10.png)
[paper notes] - target attitude estimation Epro PNP 2022 CVPR

DC-6--vulnhub靶场

Detailed explanation of C language preprocessing

MPLS experiment

Research on the influence of opinion leaders based on network analysis and text mining
随机推荐
Use localdate class to complete calendar design
基于SEIR模型的网络医疗众筹传播建模与仿真分析
Wechat applet for loop
The way of understanding JS: write a perfect combination inheritance (Es5)
【目录】Nodejs、npm、yarn、BUG
Research on visualization method of technology topic map based on clustering information
【Redis】② Redis通用命令;Redis 为什么这么快?;Redis 的数据类型
TID-MOP:面向数据交易所场景下的安全管控综合框架
Use of redis
Solve page refresh without attaching data
YOLOV3
The way of understanding JS: what is prototype chain
融合聚类信息的技术主题图可视化方法研究
实战演练 | 查找在给定时间范围内购买超过 N 件商品的客户
Pikachu靶机通关和源码分析
Markdown writing platform
What is software testing peer review?
YOLOV2 YOLO9000
Distributed transactions: the final consistency scheme of reliable messages
Research on the influence of opinion leaders based on network analysis and text mining