- 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; }
}
- 32位嵌入式系統與SoC設計導論
- 空間機器人遙操作系統及控制
- WOW!Illustrator CS6完全自學寶典
- 機器人智能運動規劃技術
- 工業機器人工程應用虛擬仿真教程:MotoSim EG-VRC
- 可編程控制器技術應用(西門子S7系列)
- Splunk Operational Intelligence Cookbook
- Dreamweaver+Photoshop+Flash+Fireworks網站建設與網頁設計完全實用
- 工業機器人入門實用教程
- WOW!Photoshop CS6完全自學寶典
- JRuby語言實戰技術
- 運動控制系統(第2版)
- 納米集成電路制造工藝(第2版)
- 工業機器人與自控系統的集成應用
- 智能座艙之車載機器人交互設計與開發