简体   繁体   中英

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.

  • Client 1: A Web Service (producer)
  • Client 2: A Windows Service (consumer)

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. 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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