PUB-SUB message ordering issue with Openfire4.4.4

When publishing many pub-sub messages to the same node in quick succession (through a single smack connection), it is seen that the message order gets jumbled when it reaches the subscriber. This used to work fine with Openfire 4.2.3.
While looking into the code, I could see that submitting the IQ messages into TaskEngine(uses a simple unbounded ThreadPoolExecutor) in PubSubEngine.process() method, was the reason for this. While it helps parallelising, it doesn’t guarantee the order of messages delivered to the same node, which are sent in quick succession.
I created an ordered executor, and used it instead of TaskEngine, and it seems to fix the ordering problem. It basically queues the messages to the same node, if there are currently any message to the same node being published. Once that is completed, the queued messages are picked up, and submitted for execution in the same order that they were received. Messages to different nodes still run in parallel unaffected.

That seems like a good find and nice improvement. Would you mind creating a PR for this?

Will create one soon.

Thanks,
Renjith

I’ve created the PR https://github.com/igniterealtime/Openfire/pull/1589.

Thanks,
Renjith.

1 Like

Closed this and opened another, after rebasing with the master: https://github.com/igniterealtime/Openfire/pull/1618

Added to the issue tracker, here: https://igniterealtime.atlassian.net/browse/OF-2147