Zmq app

We should only return documents to the source after all source documents were inserted into the target. In general, the reasons why a document might not have been inserted are:

* The connection timed out and a document was not succesfully transferred.
* The target metadata sent by the source is wrong. I have only seen these when documents are sent asynchronously from source to target and so they arrive in the "wrong" order, thus causing attempts of storing old source generations after having stored new ones.

I have not seen other reasons, but we should keep in mind that these (and others) might happen, detect when they happen, and gracefully fail the sync.