<?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: Nifi Will the ExecuteGroovyScript process the queue sequentially, or can it handle multiple queues at the same time? in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Nifi-Will-the-ExecuteGroovyScript-process-the-queue/m-p/412749#M253668</link>
    <description>&lt;P&gt;Use the Funnel processor to merge the different queues into a single one and then you can specify more than one file for the get&lt;BR /&gt;def flowFiles = session.get(10)&lt;/P&gt;</description>
    <pubDate>Sun, 26 Oct 2025 04:04:24 GMT</pubDate>
    <dc:creator>joseomjr</dc:creator>
    <dc:date>2025-10-26T04:04:24Z</dc:date>
    <item>
      <title>Nifi Will the ExecuteGroovyScript process the queue sequentially, or can it handle multiple queues at the same time?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Nifi-Will-the-ExecuteGroovyScript-process-the-queue/m-p/404351#M252312</link>
      <description>&lt;P&gt;Hello everyone,&lt;BR /&gt;I am working with Apache NiFi and I encountered the following issue:&lt;BR /&gt;The file I need to get is CaryIL-ASTUDENTDI-2025-03-18-083011.csv. The number of files in the list will change daily, and my goal is to get the file with the latest timestamp in the format yyyy-MM-dd-HHmmss.&lt;/P&gt;&lt;P&gt;Specifically, I have 5 queues containing FlowFiles, and I want to merge all the FlowFiles into a single queue. After collecting the FlowFiles from these queues, I want to select the file with the most recent date based on the file name (which follows the yyyy-MM-dd-HHmmss.csv format), and move the FlowFile with the latest date into one queue for further processing. Please refer to the attached file.&lt;BR /&gt;&lt;BR /&gt;I also tried passing them through an ExecuteGroovyScript, but it seems that it processes each queue sequentially, not merging the 5 queues into one and then finding the Latest Date time. Below is the ExecuteGroovyScript code snippet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;def flowFiles = session.get()
if (flowFiles != null &amp;amp;&amp;amp; flowFiles.iterator().hasNext()) {
    def maxLastModified = null
    def maxFile = null
    def maxFileDate = null
    def fileList = new StringBuilder()

    flowFiles.each { flowFile -&amp;gt;
        def filename = flowFile.getAttribute('filename')
        def lastModified = flowFile.getAttribute('s3.lastModified')
        log.info("Xử lý tệp: " + filename + ", s3.lastModified: " + lastModified)

        if (lastModified != null) {
            fileList.append("Filename: ${filename}, s3.lastModified: ${lastModified}\n")
            if (maxLastModified == null || Long.parseLong(lastModified) &amp;gt; Long.parseLong(maxLastModified)) {
                maxLastModified = lastModified
                maxFile = flowFile
                maxFileDate = new Date(Long.parseLong(lastModified)).format("yyyy-MM-dd-HHmmss")
            }
        }
    }

    if (maxFile != null &amp;amp;&amp;amp; maxFileDate != null) {
        def newFlowFile = session.create()
        newFlowFile = session.putAttribute(newFlowFile, "filename", maxFile.getAttribute('filename'))
        newFlowFile = session.putAttribute(newFlowFile, "s3.bucket", maxFile.getAttribute('s3.bucket'))
        newFlowFile = session.putAttribute(newFlowFile, "s3.region", maxFile.getAttribute('s3.region'))
        newFlowFile = session.putAttribute(newFlowFile, "file_date", maxFileDate)
        newFlowFile = session.putAttribute(newFlowFile, "max_file_date", maxFileDate)
        newFlowFile = session.putAttribute(newFlowFile, "latest_date", maxFileDate)
        newFlowFile = session.putAttribute(newFlowFile, "s3.lastModified", maxLastModified)
        newFlowFile = session.write(newFlowFile, { outputStream -&amp;gt;
            outputStream.write(fileList.toString().getBytes())
        } as OutputStreamCallback)

        session.transfer(newFlowFile, REL_SUCCESS)
        log.info("Tạo FlowFile mới cho tệp mới nhất: " + maxFile.getAttribute('filename') + ", max_file_date: " + maxFileDate)
    } else {
        log.warn("Không tìm thấy s3.lastModified hợp lệ. Không có tệp nào được xử lý.")
        flowFiles.each { flowFile -&amp;gt;
            session.transfer(flowFile, REL_FAILURE)
        }
    }

    flowFiles.each { flowFile -&amp;gt;
        session.remove(flowFile)
    }

    log.info("Danh sách tất cả tệp đã xử lý: " + fileList.toString())
} else {
    log.warn("Không có FlowFiles nào trong hàng đợi.")
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Mar 2025 04:07:18 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Nifi-Will-the-ExecuteGroovyScript-process-the-queue/m-p/404351#M252312</guid>
      <dc:creator>DuyChan</dc:creator>
      <dc:date>2025-03-19T04:07:18Z</dc:date>
    </item>
    <item>
      <title>Re: Nifi Will the ExecuteGroovyScript process the queue sequentially, or can it handle multiple queues at the same time?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Nifi-Will-the-ExecuteGroovyScript-process-the-queue/m-p/412749#M253668</link>
      <description>&lt;P&gt;Use the Funnel processor to merge the different queues into a single one and then you can specify more than one file for the get&lt;BR /&gt;def flowFiles = session.get(10)&lt;/P&gt;</description>
      <pubDate>Sun, 26 Oct 2025 04:04:24 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Nifi-Will-the-ExecuteGroovyScript-process-the-queue/m-p/412749#M253668</guid>
      <dc:creator>joseomjr</dc:creator>
      <dc:date>2025-10-26T04:04:24Z</dc:date>
    </item>
  </channel>
</rss>

