Clearing message queue

Hi everybody, I have the following setup. An outside software sends XML files to a web service that pushes them down a message queue. NAS stands by and reads the XML from the message queue, posts stuff in Navision and replies back to the other software via the same web service with the posted information and they do whatever with it. It all works nice and dandy except if NAS is not started or if it crashes. Then what happens is that the XML file remains in the incoming message queue and the other software times out waiting for a reply and then it stops. Now the problem when you do start NAS, if you do not manually clean the queue first, is that Navision will read the remaining XML file and process it and then send a reply but the other software is not expecting a reply. (the plan is for them to resubmit the file later). So my question is: is there a way from Navision to to flush out all content of a message queue before you start listening for new messages? Hope I explained it somewhat clear. Cristi

Unfortunately, when Navision gave us the MSMQ Bus adapter, they only exposed a very small part of both the MSMQ object model and nothing of the incoming InMessage object (they even renamed methods to boot), so there is hardly anything that you can use from the MQ. Navision clears messages from the queue with the CommitMessage command within Navision (which you probably already know). The thought behind is is noble of course, that you won’t lose any messages, but it leaves you with no flexibility if you choose to do it differently. The only way I can think of is to look at some kind of time stamp of the message and commit the ones that were submitted more than a certain time ago without processing it. I doubt that there is an exposed timestamp available in Navision though, so you’d have to include one inside your XML document.