tags:

views:

401

answers:

2

I am creating a Windows Service in C# that processes messages from a queue. I want to give ops the flexibility of partitioning the service in production according to properties of the message. For example, they should be able to say that one instance processes web orders from Customer A, another batch orders from Customer A, a third web or batch orders from Customer B, and so on.

My current solution is to assign separate queues to each customer\source combination. The process that puts orders into the queues has to make the right decision. My Windows Service can be configured to pull messages from one or more queues. It's messy, but it works.

+1  A: 

No, but you can PEEK into the queue and decide if you really want to consume the message.

Esteban Araya
A: 

Use GetMessageEnumerator2() like this:

MessageEnumerator en = q.GetMessageEnumerator2();

while (en.MoveNext()) { if (en.Current.Label == label) { string body = ((XmlDocument)en.Current.Body).OuterXml; en.RemoveCurrent(); return body; }

}

Árpád Varga