title: Post-processing after completion of Splitter
body: <p>I am trying to create an integration flow where the following actions will be performed:</p>
  
  <ol>
  <li>Call a http rest endpoint based on a cron expression to get a json response of a list of files and associated properties (like timestamp and others).</li>
  <li>Transform the response to Java model (FileInfo (containing list of FileProperties)) using a custom object mapper.</li>
  <li>Use a service activator to find the FileProperties with today's timestamp, if no such file then the flow stops here.</li>
  <li>Output from the above is used to construct a http outbound gateway to do another http rest call to get the text file content.</li>
  <li>The content is feed into a splitter to split the content into lines.</li>
  <li>Then another transformer is used to convert each line into a Java model.</li>
  <li>Then a JPA outbound gateway is used to persist that into DB.</li>
  <li>Finally another http rest call need to be made to delete the file from the server.</li>
  </ol>
  
  <p>I have devised a rough integration flow up to step 7:</p>
  
  <pre><code>&lt;bean id="jsonToFilenamesMapper"/&gt;
  &lt;bean id="sampleFileSplitter"/&gt;
  &lt;bean id="dateBasedFilter"/&gt;
  &lt;bean id="customMapper"/&gt;
  &lt;bean id="em"/&gt;
  &lt;bean id="randomCronTrigger"/&gt;
  &lt;bean id="sampleFileNameSplitter"/&gt;
  &lt;bean id="sampleFileActivator"/&gt;
  
  &lt;int:channel id="input"/&gt;
  &lt;int:channel id="output"/&gt;
  &lt;int:channel id="filenames"/&gt;
  &lt;int:channel id="reply"/&gt;
  &lt;int:channel id="csvout"/&gt;
  &lt;int:channel id="line"/&gt;
  &lt;int:channel id="extractModel"/&gt;
  &lt;int:channel id="afterSaving"/&gt;
  &lt;int:channel id="filename"/&gt;
  
  &lt;int-http:outbound-gateway request-channel="input"
                             reply-channel="output"
                             url=" https://download.com/files/"
                             http-method="GET"
                             expected-response-type="java.lang.String"&gt;
  &lt;/int-http:outbound-gateway&gt;
  
  &lt;int:inbound-channel-adapter channel="input" expression="''"&gt;
      &lt;int:poller trigger="randomCronTrigger"&gt;
      &lt;/int:poller&gt;
  &lt;/int:inbound-channel-adapter&gt;
  
  &lt;int:json-to-object-transformer input-channel="output"
                                  output-channel="filenames"
                                  type="sample.integration.FileInfo"
                                  object-mapper="jsonToFileInfoMapper"&gt;
  &lt;/int:json-to-object-transformer&gt;
  
  &lt;int:service-activator ref="sampleFileActivator"
                         input-channel="filenames"
                         output-channel="filename"&gt;
  &lt;/int:service-activator&gt;
  
  &lt;int-http:outbound-gateway request-channel="reply"
                             reply-channel="csvout"
                             url=" https://download.com/files/{filename}"
                             http-method="GET"
                             expected-response-type="java.lang.String"&gt;
      &lt;int-http:uri-variable name="filename" expression="payload.filename"/&gt;
  &lt;/int-http:outbound-gateway&gt;
  
  &lt;int:splitter input-channel="csvout"
                output-channel="line"
                ref="sampleFileSplitter"&gt;
  &lt;/int:splitter&gt;
  
  &lt;int:json-to-object-transformer input-channel="line"
                                  output-channel="extractModel"
                                  object-mapper="customMapper"&gt;
  &lt;/int:json-to-object-transformer&gt;
  
  &lt;int-jpa:updating-outbound-gateway request-channel="extractModel"
                                     reply-channel="afterSaving"
                                     persist-mode="PERSIST"
                                     entity-manager="em"&gt;
  &lt;/int-jpa:updating-outbound-gateway&gt;
  </code></pre>
  
  <p>So my questions are:</p>
  
  <ol>
  <li>How should I implement step 8, I need to know that all lines are saved to DB before calling the http endpoint to delete the file.</li>
  <li>Is the above flow looks right for requirement or there is opportunity to simplify?</li>
  <li>How does the above flow will look using Java configuration/DSL?</li>
  </ol>