当前位置:网站首页>[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
边栏推荐
- Super super super realistic digital people! Keep you on the air 24 hours a day
- In order to grasp the redis data structure, I drew 40 pictures (full version)
- Packet switching and label switching in MPLS
- mysql事务的引入
- MySQL - Multi version concurrency control (mvcc)
- Opencv learning Day6
- Flask发送验证码逻辑
- redis的使用
- 实战演练 | 查找在给定时间范围内购买超过 N 件商品的客户
- 试除法--3的幂
猜你喜欢

Nodejs starts mqtt service with an error schemaerror: expected 'schema' to be an object or Boolean problem solving

Research progress of data traceability based on the perspective of data element circulation

白蛋白纳米-超声微泡载组织型纤溶酶原激活物基因靶向制备研究

Sorting out the encapsulation classes of control elements in appium

Applet page generation link sent by SMS

牛血清白蛋白修饰牛红细胞超氧化物歧化酶SOD/叶酸偶联2-ME白蛋白纳米粒的制备

Verilog grammar basics HDL bits training 06

How to use 120 lines of code to realize an interactive and complete drag and drop upload component?

【计算一个字符串和另一个字符串相等的次数】

对“DOF: A Demand-oriented Framework for ImageDenoising“的理解
随机推荐
寻找命令find和locate
Sorting out the encapsulation classes of control elements in appium
Nodejs starts mqtt service with an error schemaerror: expected 'schema' to be an object or Boolean problem solving
数据流通交易场景下数据质量综合管理体系与技术框架研究
JVM 三色标记法与读写屏障
向左旋转k个字符串(细节)
测试7年,面试华为最后面议要薪1万,HR说我不尊重华为,他们没有那么低薪资的岗位~
自动化测试之数据驱动DDT
Understanding of "dof: a demand oriented framework for imagedenoising"
Tarjan 求强连通分量 O(n+m) ,缩点
Research on text classification of e-commerce comments based on mffmb
HOOPS Exchange助力混合计算流体动力学软件搭建3D格式导入读取功能 | 客户案例
Trial division -- power of 3
找出单身狗(力扣260)
[英雄星球七月集训LeetCode解题日报] 第25日 树状数组
MPLS experiment
Pikachu靶机通关和源码分析
Distributed transactions: the final consistency scheme of reliable messages
合肥提前批
白蛋白纳米-超声微泡载组织型纤溶酶原激活物基因靶向制备研究