jmesnil / stomp-websocket

Stomp client for Web browsers and node.js apps
http://jmesnil.net/stomp-websocket/doc/
Apache License 2.0
1.43k stars 586 forks source link

StompJS messages received out of order #108

Open Zhichao-Hong opened 9 years ago

Zhichao-Hong commented 9 years ago

I am trying to stream time series data using Springframework SimpMessagingTemplate (default Stomp implementation) to broadcast messages to a topic that the stompjs client subscribed to. However, the messages is received out of order. The server is single thread and messages are sent in ascending order by their timestamps. The client somehow received the messages out of the order.

I am using the latest release version of both stompjs and springframework (4.1.6 release).

bramhg commented 9 years ago

This should be expected in any Message oriented middleware. It is asynchronous messaging and the order of delivery can not be guaranteed. However, since your messages are time sequences you should be OK.

rfox90 commented 9 years ago

You would need to use a queue to correct this.

labrute commented 9 years ago

1) @Zhichao-Hong The name of this issue should not be "out of order" but wrong order or something like this. (out of order means "not working")

2) @bramhg : Why do you say it's asynch ? If your pushing methode is synchronous there is no reason to get a different order (with 1 publisher).

3) @rfox90 I think the websocket is already using a queue (FIFO).

The publisher is pushing data at the end of the queue, and the consumer should pop message on top of the queue. As i can see in my test, i have sent 100 messages and the consumed order is not the same as the sent order.

This issue is still open.

rfox90 commented 9 years ago

@labrute the out of sync-ness comes from the use of a topic and websockets which can disconnect re-connect etc.

using a queue on the broker over a topic is the only way to guarantee ordered message arrival. @Zhichao-Hong is using a topic.

As for your test, can you provide your broker's name and any relvant config settings. Oh and does it consume in the correct order with a non-js client. Such as Perl/Python etc.