Sling Post Servlet 500 Error with Rapid Requests or Slow Network
We're trying to use the SlingPostServlet to save content to a page when an author interacts with various input. For example, we have a checkbox in the authoring environment that will post it's "checked" status every time it is clicked. This works well, except when the user clicks the checkbox rapidly or if the network is sluggish. This causes two or more requests to go out to the same node and at least one of the responses will return a 500 internal server error with the following message -
org.apache.sling.api.resource.PersistenceException: Unable to commitchanges to session.
I'm assuming this is happening because the node is locked by the first request when the second request tries to alter the value. Is there any easy way to get around this from the server side? The only solution i've thought of is to use javascript and build a queueing system for the requests on the client side so we only allow one request at a time, but it makes me nervous to queue up data like that.
Thanks