title: Handle REST API timeout in time consuming operations
body: <p>How is possible to handle timeouts in time consuming operations in a REST API. Let's say we have the following scenario as example:</p>
  
  <ol>
  <li>A client service sends a request to insert a resource through a REST API.</li>
  <li>Timeout elapses. The client thinks the insertion failed.</li>
  <li>REST API keep working and finishes the insertion.</li>
  <li>Client do not notify the resource insertion and it status is "Failed".</li>
  </ol>
  
  <p>I can think I a solution with a message broker to send orders to a queue and wait until they are solved.</p>
  
  <p>Any other workaround?</p>
  
  <p>EDIT 1:</p>
  
  <ul>
  <li><a href="http://restalk-patterns.org/post-put.html" rel="noreferrer">POST-PUT Pattern</a> as has been suggested in this thread.</li>
  <li>A Message Broker (add more complexity to the system)</li>
  <li><a href="https://dzone.com/articles/rest-callbacks" rel="noreferrer">Callback or webhook</a>. Pass in the request a return url that the server API can call to let the client know that the work is completed.</li>
  </ul>