Asterisk offline queue messages not receive order by time


am new to Asterisk, offline messages are receiving fine, but not received based on time. offline queue messages need to deliver based on time that
msg1, msg2 ,msg3
now receiving like
msg2, msg3, msg1


Asterisk doesn’t have an offline message queue built in. You’ll need to be more specific about what exactly you are referring to.


my extensions.conf

exten => 200,1,NoOp(SMS receiving dialplan invoked)
exten => 200,n,NoOp(To ${MESSAGE(to)})
exten => 200,n,NoOp(From ${MESSAGE(from)})
exten => 200,n,NoOp(Body ${MESSAGE(body)})
exten => 200,n,AGI(chatplan.php,${MESSAGE(from)})
exten => 200,n,Set(ACTUALTO=${CUT(MESSAGE(to),@,1)})
exten => 200,n,ExecIf($["${ACTUALTO}" != “sip:${EXTEN}”]?Set(ACTUALTO=sip:${EXTEN}))
exten => 200,n,MessageSend(${ACTUALTOS},${MESSAGE(from)})
exten => 200,n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
exten => 200,n,GotoIf($["${MESSAGE_SEND_STATUS}" != “SUCCESS”]?sendfailedmsg)
exten => 200,n,Hangup()
; Handle failed messaging
exten => 200,n(sendfailedmsg),NoOp(Sending error to user)
exten => 200,n,Set(SRC=${MESSAGE(from)})
exten => 200,n,Set(DST=${MESSAGE(to)})
exten => 200,n,Set(MSG=${MESSAGE(body)})
exten => 200,n,Set(MESSAGE(body)="[${STRFTIME(${EPOCH},%d%m%Y-%H:%M:%S)}] Your message to ${EXTEN} has failed. Sending when available")
exten => 200,n,Set(ME_1=${CUT(MESSAGE(from),<,2)})
exten => 200,n,Set(ACTUALFROM=${CUT(ME_1,@,1)})
exten => 200,n,MessageSend(${ACTUALFROM},ServiceCenter)
exten => 200,n,GotoIf($["${INQUEUE}" != “1”]?startq)
exten => 200,n,Hangup()
exten => 200,n(startq),NoOp(Queueing messaging for offline)
exten => 200,n,Set(MSGTIME=${STRFTIME(${EPOCH},%d%m%Y-%H:%M:%S)})
exten => 200,n,SYSTEM(/var/lib/asterisk/agi-bin/ –SRC ‘${SRC}’ –DST ‘${DST}’ –MSG ‘${MSG}’)
exten => 200,n,Hangup()

this is my code, don’t know where i did mistake
—now i am receiving offline messages like -----------------
msg4, msg5, msg3, msg0, msg1 and etc

---------i need to receive offline messages like
msg0, msg1, msg2 and etc