当前位置:网站首页>NETCORE combined with cap event bus to realize distributed transaction - message (2)
NETCORE combined with cap event bus to realize distributed transaction - message (2)
2022-06-12 14:45:00 【There are poems and distant places】
One 、CAP Custom configuration in
- DefaultGroupName
The default value is :cap.queue.{
Assembly name }
- TopicNamePrefix
by Topic Add prefix uniformly . https://github.com/dotnetcore/CAP/pull/780
- Version
The default value is :v1
This is CAP v2.4 New configuration items introduced in version , It is used to specify the version of the message to isolate the messages of different version services , Commonly used in A/B Test or multi service version scenarios
- FailedRetryInterval
The default value is :60 second
When the message is sent , If sending fails ,CAP The message will be retried , This configuration item is used to configure the interval between retries
- SucceedMessageExpiredAfter
The default value is :24*3600 second (1 Days later )
Expiration time of the success message ( second ). When the message is sent or consumed successfully , At time SucceedMessageExpiredAfter Seconds from Persistent Delete in , You can set the expiration time by specifying this value .
Two 、 Compensation Affairs
In some cases , The consumer needs to return a value to tell the publisher the execution result , So that the publisher can implement some actions , Usually this is within the scope of compensation .
You can notify the upstream by republishing a new message in the code executed by the consumer ,CAP Provides a simple way to do this . You can specify when sending callbackName To get the implementation results of consumers , Usually this only applies to point-to-point consumption
1. Release
1. Publisher , The published routing key is angel news
2. Subscribers who receive the release , Process the message
3. Return processing results
4. Publisher , Call the callback function to
5. Release the news , The routing key is ,image
6. subscriber image, Receive release , Process the message
_capBus.Publish("angel", contentObj: new Person {
Id = 1, Name = "11" },callbackName:"image");
[NonAction]
[CapSubscribe("angel")]
public Person ReceiveMsg(Person str)
{
if(str!=null)
{
Console.WriteLine($" receive {
str.Id}");
_log.LogInformation($" I'm a subscriber , The content received is :{
str.Id},{
str.Name}");
// The result of processing , Return back
return str;
}
throw new Exception();
}
[NonAction]
[CapSubscribe("image")]
public void CallBackMsg(Person str)
{
if(str!=null)
{
Console.WriteLine($" Callback {
str.Id}");
_log.LogInformation($" I'm a callback , The contents of the callback are :{
str.Id},{
str.Name}");
}
}
边栏推荐
- 【Optional】1. Map and ifpresent 2 Ofnullable and orelse
- 你敢信?開發一個管理系統我只用了兩天
- Unhandled exception stack overflow
- Word insert picture blocked by text
- C語言中主函數調用另外一個函數,匯編代碼理解
- recursive learning
- 我愿称之为史上最全的深度学习面经总结(附答案详解)
- Junit异常情况,断言异常信息不为空过的方法
- C secret arts script Chapter 2 (detailed explanation of pointer) (Section 2)
- Ankai microelectronics rushes to the scientific innovation board: the annual revenue of 500million Xiaomi industry fund is the shareholder
猜你喜欢

亿纬锂能拟募资90亿:刘金成骆锦红夫妇合计认购60亿 布局光谷

Can you believe it? It took me only two days to develop a management system

Jetpack架构组件学习(3)——Activity Results API使用

Perfect ending | detailed explanation of the implementation principle of go Distributed Link Tracking

MobileOne: 移动端仅需1ms的高性能骨干,你值得拥有!

Interview (XI) futu written test questions

JUnit test suite method sorting (method 2 is not easy to use)

Serialization and deserialization mechanism in terms of games

阿里建议所有 POJO 类属性使用包装类,但这些坑你有注意到吗?

Getting started with webdriver
随机推荐
New technology: efficient self-monitoring visual pre training, local occlusion no longer need to worry!
交换数字,异或求单,操作符相关
Thinking: what is asynchrony and thread safety
Appnium (I) basic use of appnium
Mobileone: the mobile terminal only needs 1ms of high-performance backbone. You deserve it!
Visual positioning guidance system for industrial manipulator (robot)
PMP敏捷知识点
jenkins的RPC测试项目
Autofac初学(1)
左对齐,右对齐,随机数,goto,比较输出bool
Junit异常情况,断言异常信息不为空过的方法
Basic usage of scanner
C secret script Chapter 3 (detailed explanation of string function) (Section 2)
Ankai microelectronics rushes to the scientific innovation board: the annual revenue of 500million Xiaomi industry fund is the shareholder
启明智显分享| 2.8寸手持中控屏应用方案
Writing method of JUnit multithreading
webdriver入门
【Optional】1. Map and ifpresent 2 Ofnullable and orelse
[wechat applet] 3 The first wechat applet
Common assertions in JUnit testing