Can I filter messages that I receive from Message Queuing (MSMQ) by some property? (aka theme)

I am creating a Windows service in C # that processes messages from a queue. I want to give ops the flexibility of sharing services in production according to the properties of the message. For example, they should be able to say that one instance processes web orders from client A, other batches of orders from client A, a third web or batch order from client B, etc.

My current solution is to assign separate queues to each client \ source combination. The process that queues orders must make the right decision. My Windows service can be configured to migrate messages from one or more queues. This is messy, but it works.

+4
source share
2 answers

No, but you can peek into the queue and decide if you really want to use this message.

+5
source

Use GetMessageEnumerator2 () as follows:

MessageEnumerator en = q.GetMessageEnumerator2(); while (en.MoveNext()) { if (en.Current.Label == label) { string body = ((XmlDocument)en.Current.Body).OuterXml; en.RemoveCurrent(); return body; } } 
+3
source

Source: https://habr.com/ru/post/1276693/


All Articles