MessageManager - message order


#1

Hello,

I’m using MessageManager, but messages from Device, are not always with right order, I mean:

2017-06-06 00:51:06 +03:00 [Agent] id: 50 , data: 2017-06-06 00:51:05|0c2a6904f87d|irrig|Function “run”->“stopScheduler” - sopping schedule 7days zone 6 , timestamp: 2017-06-06 00:51:05
2017-06-06 00:52:02 +03:00 [Agent] id: 52 , data: 2017-06-06 00:52:01|0c2a6904f87d|debug|Function “checkZones” refresh time: 00:52
2017-06-06 00:52:02 +03:00 [Agent] id: 51 , data: 2017-06-06 00:52:01|0c2a6904f87d|debug|Function “cancel” - number of EVENTS that will be canceled : 13
2017-06-06 00:52:02 +03:00 [Agent] id: 53 , data: 2017-06-06 00:52:01|0c2a6904f87d|debug|Function “secondsTil” - secondsTill : 86400 , timestmap: 2017-06-06 00:52:01

Can somebody tell me, how (if it is possible) Device to send messages in right order ?


#2

I guess, the issue is that messages are not sorted by id, right? If so, you can control message order in the beforeSend, beforeRetry handlers by checking id of the currently processed message with one which was successfully sent/confirmed (onAck). You can delay transmission of those that are out of order.

I hope this is helpful. Please let me know if you have any questions.


#3

Thanks - beforeRetry do the trick. Something like:

msgIDCounter <- 1
mm.beforeRetry(
function(msg, skip, drop) {
if(msg.payload.id>msgIDCounter) {
// cm.log("Message ID: “+msg.payload.id+” , counter ID: "+msgIDCounter)
skip(0.4)
}
msgIDCounter = msg.payload.id
}
)

If some one has a better idea … share :slight_smile: