- Hands-On Microservices with C#
- Matt R. Cole
- 219字
- 2021-07-23 17:25:21
Versioning messages
Even though I can honestly say that I have developed interfaces that could accommodate any change made to both sides without ever modifying the interface, most people don't design to that extreme. There will, more likely than not, come a time where you will have to change a message to accommodate a new feature or request, and so on. Now, we get into the issue of message versioning.
To enable support for versioned messages, we need to ensure the required components are configured. The simplest way to achieve this is as follows:
var bus = RabbitHutch.CreateBus( "host=localhost", services => services.EnableMessageVersioning() )
Once support for versioned messages is enabled, we must explicitly opt-in any messages we want to be treated as versioned. So as an example, let's say we have a message defined called MyMessage. As you can see in the following message, it is not versioned and all versions will be treated the same way as any other when it is published:
public class MyMessage
{
public string Text { get; set; }
}
The next message that you see will be versioned, and ultimately it will find its way to both the V2 and previous subscribers by using the ISupersede interface:
public class MyMessageV2 : MyMessage, ISupersede<MyMessage>
{
public int Number { get; set; }
}
- 繪制進(jìn)程圖:可視化D++語言(第1冊)
- 蕩胸生層云:C語言開發(fā)修行實(shí)錄
- TIBCO Spotfire:A Comprehensive Primer(Second Edition)
- Hadoop Real-World Solutions Cookbook(Second Edition)
- CentOS 8 Essentials
- 傳感器與物聯(lián)網(wǎng)技術(shù)
- 西門子變頻器技術(shù)入門及實(shí)踐
- 網(wǎng)站入侵與腳本攻防修煉
- SQL Server數(shù)據(jù)庫應(yīng)用基礎(chǔ)(第2版)
- 基于Proteus的單片機(jī)應(yīng)用技術(shù)
- 數(shù)據(jù)要素:全球經(jīng)濟(jì)社會發(fā)展的新動力
- MongoDB 4 Quick Start Guide
- 西門子S7-1200/1500 PLC從入門到精通
- 數(shù)據(jù)結(jié)構(gòu)與實(shí)訓(xùn)
- VMware vSphere 6.5 Cookbook(Third Edition)