【问题标题】:how to get list of flowfile from queue in nifi connection?如何从 nifi 连接中的队列中获取流文件列表?
【发布时间】:2019-04-13 06:14:59
【问题描述】:

当流被 NiFi REST API 阻止时,我想从队列中获取每个流文件。

我发现/nifi-api/flowfile-queues/{id}/listing-requests的功能可以满足我的需求。它响应了一个ListingRequestDTO: enter image description here

名为flowFileSummaries的字段可以返回一个flowFile数组。然后我可以从flowfiles中获取每个uuid:

{
"uri": "value",
"uuid": "value",
"filename": "value",
"position": 0,
"size": 0,
"queuedDuration": 0,
"lineageDuration": 0,
"clusterNodeId": "value",
"clusterNodeAddress": "value",
"penalized": true

}

但是,当我使用 API 时,找不到“FlowFileSummary”

{
"listingRequest": {
    "id": "0165122a-e1ac-134e-2c09-92ba9ca93e8b",
    "uri": "http://.../nifi-api/flowfile-queues/07a23828-d6f3-1e00-27af-f0428a493507/listing-requests/0165122a-e1ac-134e-2c09-92ba9ca93e8b",
    "submissionTime": "09/07/2018 18:46:57.496 CST",
    "lastUpdated": "18:46:57 CST",
    "percentCompleted": 0,
    "finished": false,
    "maxResults": 100,
    "state": "Waiting for other queue requests to complete",
    "queueSize": {
        "byteCount": 370689,
        "objectCount": 995
    },
    "sourceRunning": false,
    "destinationRunning": false
}

}

那么,有没有可能的解决方案来实现?或任何其他解决方案?谢谢!

【问题讨论】:

    标签: apache-nifi


    【解决方案1】:

    我认为在列表请求完成之前无法获得流文件摘要。在上面的示例响应中,请注意 finished 是错误的。您可以继续查询该列表请求的 API,直到 finished 为真,然后摘要应该可用。然后你可以使用/flowfile-queues/{id}/flowfiles/{flowfile-uuid}/flowfile-queues/{id}/flowfiles/{flowfile-uuid}/content端点来获取每个流文件的属性和内容。

    【讨论】:

    • 非常感谢。看了很多你的回答,从中学到了很多。我还是不知道怎么让finished转向true。但我解决了这个问题。我发现listingRequest 的字段uri/flowfile-queues/{id}/listing-requests/{listing-request-id},我可以使用这个uri 从GET 中获取摘要。所以,我想问两个问题: 1. 如何使列表请求完整? 2. 什么是listing-request-id?再次感谢!
    【解决方案2】:

    您不需要完成列表请求。以下是我成功获取流文件内容的步骤

    1. 从 NiFi UI 控制台获取队列的 ID
    2. 在此处替换 id:curl -X POST https://myhost:443/nifi-api/flowfile-queues/{id}/listing-requests -H 'Authorization: Bearer' --compressed --insecure
    3. 要获取队列中流文件的 uri,请从 step2 中命令的响应中获取“uri”字段的值,并在下一个 curl 命令中使用它,例如: 例如: curl -X GET https://myhost:443/nifi-api/flowfile-queues/0f66c88c-225d-3229-b2e1-597d8fba2c09/listing-requests/13802f9c-016a-1000-0000-00004eb033fb -H 'Authorization: Bearer' --compressed --insecure
    4. 要获取流文件内容,请从 step3 中命令的响应中获取 'uri' 字段的值,并在下一个 curl 命令中使用它,例如: curl -X GET https://myhost:443/nifi-api/flowfile-queues/0f66c88c-225d-3229-b2e1-597d8fba2c09/flowfiles/7ccf5c54-7c8d-448a-a124-7f75f5845ec1?clusterNodeId=35a3df65-d7bf-47d2-b162-ea15c3c02c30 -H '授权:' --compressed --insecure

    注意:如果有多个流文件,您会在第 3 步 curl 命令的响应中看到多个 URI

    【讨论】:

      猜你喜欢
      • 2017-10-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多