Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cf.net queuing for webservice

This question is related to this other question I recently asked...

cf.net exception and other logging

I am generating log messages to be sent to a server using a webservice over a GPRS connection and I want to simply queue these messages in the case the connection to the server is not available. Later I may also want to batch them to save bandwidth. What is best (easiest) way of doing this using cf.net. I need the queue to be somehow persisted across app restarts and preferably across device restarts.

Does anyone have any advice? Or better still a code example :)

Many Thanks.

like image 753
Christopher Edwards Avatar asked Sep 16 '26 18:09

Christopher Edwards


2 Answers

Typically what I've done is push the data into a database table (SQLCE is my typical route). When I need to push something to the web service, I send it to the dispatcher, which in turns puts it into the database. The dispatcher has a background thread that pulls data out of the database, sends it, then does a database delete upon successful send. It also monitors connection state.

A queue in the dispatcher is a little cleaner and faster, but your desire to persist across app and device restarts requires persistent storage, so a database is probably the simplest mechanism.

like image 154
ctacke Avatar answered Sep 18 '26 09:09

ctacke


I've used a SQL Compact database for doing this sort of thing (and a lot more). I've never had any problems and you probably already know all the skills required. Basically store the messages in the database and delete them once they are successfully uploaded.

Using MSMQ for the Compact Framework is a decent alternative if you are familiar with regular MSMQ.

As an aside, we conserve the power on Windows Mobile devices by switching the phone capabilities off all the time other than when it is need, ie. for GPRS data transfer. This can improve battery life considerably if it is viable for your situation (ours are never used apart from our application, they are scanners with WM on them rather than mobile phones).

like image 29
Garry Shutler Avatar answered Sep 18 '26 09:09

Garry Shutler



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!