🎄 Happy Holidays! 🥳
Most of Solace is closed December 24–January 1 so our employees can spend time with their families. We will re-open Thursday, January 2, 2024. Please expect slower response times during this period and open a support ticket for anything needing immediate assistance.
Happy Holidays!
Please note: most of Solace is closed December 25–January 2, and will re-open Tuesday, January 3, 2023.
Queue with random order?
How can we enable this?
Answers
-
Yes haha, it really contradicts the principle of queues. But it would be cool if there was such a possibility. However, messages must not be lost :( We do need that property of queues already...
We've also experimented with prioritization. If the sender assigns a random priority from 0 to 9, then younger events could pass older events, but then it would be semi-randomized. Additionally, the sender would have to take care of that, which also bloats the code…1 -
In principle you can't ever get complete knowledge about whether a younger event is "about to arrive" at the message destination, because "about to arrive" encompasses multiple possibilities:
1. The destination has buffered multiple events associated with the same entity
2. You are using guaranteed messages and the broker infrastructure has multiple events in a subscriber's queue associated with the same entity
3. The publisher is currently in the process of publishing a new message for an entity, while the broker queue, or the subscriber, already has on older event for that entity.The only one you can control is (1), so controlling this should happen on the subscriber side.
In my opinion the best solution is to have the subscriber receive messages into a buffer. You then release messages in batches. A batch would be released when, say, 500 messages are buffered, or some amount of time elapses, whichever comes first (tweak these numbers for your use case).
You then deduplicate the batch in the subscriber processing code, keeping only the most recent message for each entity (and immediately acknowledging all of the older messages without processing them if you are doing guaranteed delivery). A subset of the batch, containing only the most recent messages, then proceeds through to normal message processing.
1