def flowFile = session.get()
if(!flowFile) return
// Executescript attributes
def serviceName = dbcp.value
def sqlCmdString = sqlCmd.value
def jsonSlurper = new JsonSlurper()
// get controller service lookup from context
def lookup = context.controllerServiceLookup
// search for serviceName in controller services
def dbcpServiceId = lookup.getControllerServiceIdentifiers(ControllerService).find {
cs -> lookup.getControllerServiceName(cs) == serviceName
}
//Get the service from serviceid
def service = lookup.getControllerService(dbcpServiceId)
// Connect to service
def conn = service.getConnection()
if (!conn) {
log.error("Failed to connect to " + serviceName)
return;
}
try {
//flowFile = session.create()
flowFile = session.write(flowFile, {out ->
def sql = new Sql(conn)
if (!sql) {
log.error("Failed to get SQL connection")
return
}
//def sqlCmdString = "ExecuteScript Attributs info"
def rows = sql.rows(sqlCmdString)
"""
i want to know the part that decompresses select return value and transfers json file to lower flow file.
"""
} as OutputStreamCallback)
session.transfer(flowFile, REL_SUCCESS)
} catch(e) {
conn?.close()
log.error("Scripting error " + sqlCmd, e)
session.transfer(flowFile, REL_FAILURE)
}
// Release connection, this is important as it will otherwise block new executions
conn?.close()