简体   繁体   English

JMS:更新消息版本/防止某些消息进入队列

[英]JMS: updating message version / prevent certain message from being queued

I am trying to create a message based application based with ActiveMQ, using .NET Clients. 我正在尝试使用.NET客户端创建基于ActiveMQ的基于消息的应用程序。

  • Client 1: A Web Service (producer) 客户端1:Web服务(生产者)
  • Client 2: A Windows Service (consumer) 客户端2:Windows服务(消费者)

My question is: Is it possible to prevent messages of a certain type or content from being queued by a Client? 我的问题是:是否可以防止客户端将某种类型或内容的消息排队?

The reason why I want to do this is Version Updating. 我要执行此操作的原因是版本更新。

I think there will be a time, when I need to extend or change the message type. 我认为会有一段时间,我需要扩展或更改消息类型。 My plan is to do that update in the following order: 我的计划是按以下顺序进行更新:

  1. Prevent messages of the old version to be queued. 防止将旧版本的消息排队。
  2. Wait until the consumer has processed all messages of the old version. 等待直到使用者处理完所有旧版本的消息。
  3. Update producer and consumer software. 更新生产者和使用者软件。

I would like the Web Service to be still available during the update process to report back to the call. 我希望在更新过程中Web服务仍然可用,以便向呼叫报告。 But it should not be able to queue new messages. 但是它不能将新消息排队。

Of course if there is a better way of solving this problem altogether, please let me know. 当然,如果有更好的方法可以完全解决此问题,请告诉我。

As a general rule it is a good idea to only have one type of payload per queue. 通常,每个队列只有一种类型的有效负载是一个好主意。 An easy way to do this is to use two different queues for the two different message versions. 一种简单的方法是对两个不同的消息版本使用两个不同的队列。 Something like: 就像是:

mysystem.orders.1_0
mysystem.orders.1_1

The version should be the last part of the queue name, as it makes it easy to work with wildcards , which are used for a lot of the config options in ActiveMQ. 版本应该是队列名称的最后一部分,因为它可以轻松使用通配符通配符用于ActiveMQ中的许多配置选项。

Splitting up different versions into different queues gets you around the problem of having to upgrade the producer and consumer at the same time, and also gives you some visibility as whether all of the 1_0 messages have been consumed. 将不同的版本划分为不同的队列可以解决必须同时升级生产者和使用者的问题,并且还可以使您了解是否所有1_0消息都已耗尽。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM