You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

NiFi 1.5.0及旧版本如何批量清除所有队列?

Great question! When you’re managing a NiFi 1.5.0 instance (and older versions with the same core logic), manually resetting each queue one by one gets really tedious as your processor count grows. Luckily, there are two straightforward ways to clear all queues at once—one using the UI, and another leveraging the NiFi API:

Clear All Queues via the NiFi UI

This is the simplest method if you prefer working directly in the NiFi interface:

  • Open the Operate Palette (click the square icon in the top-right corner, or use the keyboard shortcut Ctrl+Alt+O).
  • Switch to the Connections tab in the palette.
  • Check the box at the very top of the connections list to select all connections in your flow.
  • Look for the Empty Queue button (marked with a trash can icon) in the toolbar above the list, then click it.
  • Confirm the action when the prompt appears, and NiFi will clear every selected queue in a single operation.
Clear All Queues via the NiFi API

If you want to automate this process or run it remotely, the NiFi API is your friend. Below are examples for both unsecure and secure NiFi instances:

Unsecure NiFi Instance

You’ll need jq installed to parse the JSON response and extract connection IDs (it’s a lightweight JSON processor you can install via most package managers):

# Fetch all connection IDs from your NiFi instance
CONNECTIONS=$(curl -s "http://your-nifi-host:port/nifi-api/connections" | jq -r '.connections[] | .id')

# Loop through each connection and send the empty queue request
for CONN_ID in $CONNECTIONS; do
  curl -X POST "http://your-nifi-host:port/nifi-api/connections/$CONN_ID/empty"
done

Secure NiFi Instance

For secure instances, you’ll first need to obtain an access token to authenticate your requests:

# Get an access token (replace with your username, password, and NiFi URL)
TOKEN=$(curl -s -X POST "https://your-nifi-host:port/nifi-api/access/token" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "username=your-username&password=your-password" | tr -d '"')

# Fetch all connection IDs using the token
CONNECTIONS=$(curl -s -H "Authorization: Bearer $TOKEN" \
  "https://your-nifi-host:port/nifi-api/connections" | jq -r '.connections[] | .id')

# Empty each queue
for CONN_ID in $CONNECTIONS; do
  curl -X POST -H "Authorization: Bearer $TOKEN" \
    "https://your-nifi-host:port/nifi-api/connections/$CONN_ID/empty"
done

Quick Notes:

  • Always double-check before emptying queues—this action permanently deletes all queued flow files, and there’s no undo!
  • This only affects runtime queued data; your flow definition itself remains untouched.

内容的提问来源于stack exchange,提问作者Félicien

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 07:18:42