Consider a queue of items on server. The client then reads 10 queued items at a time using a REST web service. Naturally, when the client has consumed these items the server should remove them server-side.
Q: What is the best approach if we consider both robustness, network load and restfulness?
I can think of three possible solutions:
The client asks for new items. The server then...
- sends item 1..10 (
GET
) and removes them immediately. Hopefully the items arrived at the client. - sends item 1..10 (
GET
), client sends ACK for 1..10 (DELETE
), and the server removes the items. - sends item 1..10 (
GET
). Next time the client asks for 11..20 (GET
), the previous items are removed on the server.
I believe both #1 and #3 violate the restful principle. E.g. Only the DELETE
method may delete objects. However, they both avoid the data traffic for the ACK command.
Not sure what's best here. Perhaps there is an even better solution?