Network queuing system

I wish to implement some sort of network queuing system. So basically, when a method wants to send some data to the server, it will try first and if it fails, then add it to a "queue" and try to send x seconds again later.

Generally, the data which is being sent to the server is 2 strings, on after the other. The first being an id of some sort, the next being a string which is formatted in XML.

It would be nice if this queue could survive a termination of the application.

Any ideas on how to implement such a thing? Maybe I'm going about this a completly wrong way?

I have this idea of saving the xml files to the hard drive in a queue folder and having a thread constantly running in the background to check for files in this folder and try to send them to the server. Maye there is a better way for this?

You're better off approaching this by writing out an XML file to disk in a directory, then processing the directory and deleting the files if the network send fails. This way you will always have the same command life cycle of generate command -> write to disk -> read from disk -> send -> delete if successful.

Otherwise you will have more code paths and in the long run your solution will probably be hard to maintain. Why don't you have some sort of database running on the till to write the 'commands' to and process it from there? I do extensive POS integration and most registers have a local database that synchs to a primary database so the register can run offline.

My aim is to get the till to send an XML file (which I call a TRN) of the transaction just processed to the server. This allows "real-time" stats as well as refunds from other tills (If, for example the refund system was complex and needed a receipt scanned or something).

Now, at the "End of Day", the till will still do a proper sync and verify (Whether that be by syncing databases or re-sending all the xml files again in a zipped file I havn't decided yet).

The sending of the TRN after each transaction is just an added feature really.