title: How to handle multiple REST calls when process single message
body: <p>I have created a REST API, which is being called from a Spring Integration application.  Currently messages are coming into the SI application with the following payload. </p>
  
  <pre><code>{
    "trackNumber" : "XYZ123",
    "products": [
      {"model" : "MODEL",
       "description" : "NAME"
      }]
  }
  </code></pre>
  
  <p>The current REST API can handle this payload as a single POST using the following configuration.    </p>
  
  <pre><code>&lt;int:chain id="chain" input-channel="addChannel"&gt;               
          &lt;int:header-enricher &gt;
              &lt;int:header name="content-type" value="application/json"&gt;&lt;/int:header&gt;  
          &lt;/int:header-enricher&gt;
          &lt;int-http:outbound-gateway id="appointment"
              url="http://test.com/appointments/"
              http-method="POST"
              expected-response-type="java.lang.String"
              charset="UTF-8"/&gt;       
      &lt;/int:chain&gt;
  </code></pre>
  
  <p>Now what I'm wondering is how to process the messages by calling a POST to create the entity with only the track number.</p>
  
  <p>Then make another POST call for each of the products.</p>
  
  <p>Once I break out the separate calls, the http outbound-gateway will not work any more because it doesn't pass the complete message so I can't make another call for creating the products.</p>
  
  <p>The other thing I'm having issues with is handling a failure.  For example if a product doesn't save and fails, then how would I best handle the reprocessing of the original message?</p>
  
  <p>Also reference my other question where I talk about using spring data rest.</p>
  
  <p><a href="https://stackoverflow.com/questions/24356680/cant-post-a-collection">Can&#39;t POST a collection</a></p>