简体   繁体   中英

Queueing and Isolated Storage

I have a small application that queues some requests and pulls them off the stack.

However, the application on the server servicing the queue may at any point fail and I need to be able to rebuild the queue when the application starts up again. This cannot be handled in a database as the database reads and writes are slow in this environment hence the queueing to at least give the user the perception of speed.

Does anyone know of a library that will enable me to store the queue in isolated storage. It would need to be able to maintain the queue at any time during enqueue and dequeue opperations.

The only thing I have tried thus far is to serialize the queue items as they are pushed onto the queue but now am stuck with the pull as to the approach which is why I was hoping there might be a library.

edit

Is the answer to simply reserialise the entire queue everytime there is a enqueue and dequeue ?

And how would I " peek " at the entire queue to get all the items in the first place?

My first advise would be to use ActiveMQ or RabbitMQ , both uses persistence, with fail over, they are very easy to pick up. ActiveMQ has its own database as well as you can plugin your own database.

If you dont want to use database, ActiveMQ still persist the data at temp files and provides you reliability.

If you dont want to use these products, you can use a ConcurrentQueue , and whenever you enqueue, asynchronously write that to a isolated storage, then you ll have to maintain it when you dequeue. Also, you might consider seperate app domain for this part so if your main app goes down, you can still have your queue running.

I believe you will have more cases to cover this is just intuitive.

Edit:

Serializing the entire queue would slow you down a lot as serialization is expensive.
Peek is implemented as a feature of every queue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM