- 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; }
}
- Hands-On Intelligent Agents with OpenAI Gym
- Unreal Engine:Game Development from A to Z
- 智能工業報警系統
- Multimedia Programming with Pure Data
- 統計學習理論與方法:R語言版
- 傳感器與新聞
- 教育機器人的風口:全球發展現狀及趨勢
- FPGA/CPLD應用技術(Verilog語言版)
- Excel 2010函數與公式速查手冊
- 寒江獨釣:Windows內核安全編程
- 中國戰略性新興產業研究與發展·數控系統
- Effective Business Intelligence with QuickSight
- 自適應學習:人工智能時代的教育革命
- Embedded Linux Development using Yocto Projects(Second Edition)
- 傳感技術基礎與技能實訓