<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Delete/Stop flow files in execute script in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Delete-Stop-flow-files-in-execute-script/m-p/188379#M75996</link>
    <description>&lt;A rel="user" href="https://community.cloudera.com/users/69433/rameshtec1991.html" nodeid="69433" target="_blank"&gt;@Pavan M&lt;/A&gt;&lt;P&gt;As you are not transferring any of the &lt;STRONG&gt;flowfiles&lt;/STRONG&gt; to &lt;STRONG&gt;REL_FAILURE&lt;/STRONG&gt;, Transfer the else  &lt;STRONG&gt;flowfiles to failure relation&lt;/STRONG&gt; and &lt;STRONG&gt;auto terminate the failure relation&lt;/STRONG&gt;,&lt;/P&gt;&lt;PRE&gt;else:
session.transfer(flowFile, REL_FAILURE)&lt;/PRE&gt;&lt;P&gt;Auto terminate failure relation&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="64666-executescript.png" style="width: 1793px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/18650i7C4B6112591D8A40/image-size/medium?v=v2&amp;amp;px=400" role="button" title="64666-executescript.png" alt="64666-executescript.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;(or) &lt;/P&gt;&lt;P&gt;You can use session.remove to remove the flowfile&lt;/P&gt;&lt;PRE&gt;else:&lt;BR /&gt;session.remove(flowFile)&lt;/PRE&gt;&lt;P&gt;by using any of the above ways you can achieve same result as you are expecting.&lt;/P&gt;</description>
    <pubDate>Sun, 18 Aug 2019 07:53:58 GMT</pubDate>
    <dc:creator>Shu_ashu</dc:creator>
    <dc:date>2019-08-18T07:53:58Z</dc:date>
    <item>
      <title>Delete/Stop flow files in execute script</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Delete-Stop-flow-files-in-execute-script/m-p/188376#M75993</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;I want to either delete or stop the flow files which didn't satisfy the condition in execute script.&lt;/P&gt;&lt;P&gt;I'm getting lot of flow files into my execute script processor out of which didn't satisfy the condition needs to be stopped/deleted at the execute script processor it self and whichever the flow files satisfy the condition needs to move to the next step. Can we stop/delete the flow files in execute script processor. &lt;/P&gt;&lt;P&gt;Below is the logic inside the execute script.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="64639-screen-shot-2018-03-16-at-54506-pm.png" style="width: 476px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/18652i03CA512BEFBEEBEA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="64639-screen-shot-2018-03-16-at-54506-pm.png" alt="64639-screen-shot-2018-03-16-at-54506-pm.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Aug 2019 07:54:14 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Delete-Stop-flow-files-in-execute-script/m-p/188376#M75993</guid>
      <dc:creator>rameshtec1991</dc:creator>
      <dc:date>2019-08-18T07:54:14Z</dc:date>
    </item>
    <item>
      <title>Re: Delete/Stop flow files in execute script</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Delete-Stop-flow-files-in-execute-script/m-p/188377#M75994</link>
      <description>&lt;A rel="user" href="https://community.cloudera.com/users/69433/rameshtec1991.html" nodeid="69433"&gt;@Pavan M&lt;/A&gt;&lt;BR /&gt;&lt;P&gt;It might be easier to stop/delete the flow files before they get to the ExecuteScript processor using the RouteText processor.&lt;/P&gt;</description>
      <pubDate>Sat, 17 Mar 2018 01:08:51 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Delete-Stop-flow-files-in-execute-script/m-p/188377#M75994</guid>
      <dc:creator>Wynner</dc:creator>
      <dc:date>2018-03-17T01:08:51Z</dc:date>
    </item>
    <item>
      <title>Re: Delete/Stop flow files in execute script</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Delete-Stop-flow-files-in-execute-script/m-p/188378#M75995</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/69433/rameshtec1991.html" nodeid="69433" target="_blank"&gt;@Pavan M&lt;/A&gt; You can use the remove method from the session object. Follows an example.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;NiFi Flow&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="64662-screen-shot-2018-03-17-at-24346-am.png" style="width: 1888px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/18651i71B802F4B1B75217/image-size/medium?v=v2&amp;amp;px=400" role="button" title="64662-screen-shot-2018-03-17-at-24346-am.png" alt="64662-screen-shot-2018-03-17-at-24346-am.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;Each GenerateFlowFile processor generate an empty flow with an attributed called "a" valued 1, 2 &amp;amp; 3 respectively.&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Script in ExecuteScript processor&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;flowFile = session.get() 
a = int(flowFile.getAttribute('a')) 

if(a == 1): 
 session.transfer(flowFile, REL_FAILURE) 
elif(a == 2): 
 session.transfer(flowFile, REL_SUCCESS) 
else: 
 session.remove(flowFile)&lt;/PRE&gt;&lt;P&gt;So the flowFiles with &lt;EM&gt;"a"&lt;/EM&gt; equalling 1 or 2 are being redirected accordingly while the others are removed. You can see that SUCCESS and FAILURE relation have 1 flow file each. The third one has been deleted.&lt;/P&gt;&lt;P&gt;You can modify the above script according to your business logic and you should be good.&lt;/P&gt;&lt;P&gt;Hope that helps!&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P style="margin-left: 20px;"&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Aug 2019 07:54:06 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Delete-Stop-flow-files-in-execute-script/m-p/188378#M75995</guid>
      <dc:creator>RahulSoni</dc:creator>
      <dc:date>2019-08-18T07:54:06Z</dc:date>
    </item>
    <item>
      <title>Re: Delete/Stop flow files in execute script</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Delete-Stop-flow-files-in-execute-script/m-p/188379#M75996</link>
      <description>&lt;A rel="user" href="https://community.cloudera.com/users/69433/rameshtec1991.html" nodeid="69433" target="_blank"&gt;@Pavan M&lt;/A&gt;&lt;P&gt;As you are not transferring any of the &lt;STRONG&gt;flowfiles&lt;/STRONG&gt; to &lt;STRONG&gt;REL_FAILURE&lt;/STRONG&gt;, Transfer the else  &lt;STRONG&gt;flowfiles to failure relation&lt;/STRONG&gt; and &lt;STRONG&gt;auto terminate the failure relation&lt;/STRONG&gt;,&lt;/P&gt;&lt;PRE&gt;else:
session.transfer(flowFile, REL_FAILURE)&lt;/PRE&gt;&lt;P&gt;Auto terminate failure relation&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="64666-executescript.png" style="width: 1793px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/18650i7C4B6112591D8A40/image-size/medium?v=v2&amp;amp;px=400" role="button" title="64666-executescript.png" alt="64666-executescript.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;(or) &lt;/P&gt;&lt;P&gt;You can use session.remove to remove the flowfile&lt;/P&gt;&lt;PRE&gt;else:&lt;BR /&gt;session.remove(flowFile)&lt;/PRE&gt;&lt;P&gt;by using any of the above ways you can achieve same result as you are expecting.&lt;/P&gt;</description>
      <pubDate>Sun, 18 Aug 2019 07:53:58 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Delete-Stop-flow-files-in-execute-script/m-p/188379#M75996</guid>
      <dc:creator>Shu_ashu</dc:creator>
      <dc:date>2019-08-18T07:53:58Z</dc:date>
    </item>
  </channel>
</rss>

