NIFI 儲存資料流到本地py指令碼
阿新 • • 發佈:2018-11-01
import json
import java.io
from org.apache.commons.io import IOUtils
from java.nio.charset import StandardCharsets
from org.apache.nifi.processor.io import StreamCallback
from org.apache.nifi.processor.exception import ProcessException
class PPutfile(StreamCallback):
def __init__(self):
pass
def process(self,inputStream,outputStream):
text = IOUtils.toString(inputStream,StandardCharsets.UTF_8)
f.write(text)
flowfile = session.get()
try:
if (flowfile != None):
filename = flowfile.getAttribute("filename")
f = open("E:\\fdata\\t"+filename,'a+')
flowfile = session.write(flowfile,PPutfile())
f.close()
session.transfer(flowfile, REL_SUCCESS)
except :ProcessException
求職呀。。。。。。。。應屆生 qq微信:1255745139