Reputation: 764
My application must process messages from clients in a specific order. If messages contain the same tag, these messages must be processed sequentially, they can not be processed simultaneously in different threads. Messages with the same tag may be obtained from different clients. Tags are not pre-specified. How to implement this requirement? Are there out-of-box solution, queues with this feature, something else...
Upvotes: 0
Views: 160
Reputation: 764
I found the answer myself. http://docs.masstransit-project.com/en/latest/overview/keyideas.html#sagas
Upvotes: 0
Reputation: 1736
That looks similar to 'priority queue' data structure, but instead of priority you'd process messages distinguishing them by tag.
Not sure what exact needs are, but it should be pretty straightforward to implement:
class TagQueue {
Dictionary<Tag, Queue> _queues;
void Enqueue(tag, payload) {
_queues[tag].Enqueue(payload);
}
Payload Dequeue(tag) {
return _queues[tag].Dequeue();
}
Ienumerable<Tag> Tags { get { return _queues.Keys } };
}
Upvotes: 1