Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

how to get access to StandardProcessSession and StandardRepositoryContext from a custom processor code?

Highlighted

how to get access to StandardProcessSession and StandardRepositoryContext from a custom processor code?

New Contributor

HI all,

I'm working in a custom processor which has to handle log messages, each message has to include information such as the name of incoming connection i.e "try", "failure", "no retry" etc. as well as processor origin name, processor group name and so on.

While I debugged nifi logMessage processor I got StandardRepositoryContext and StandardProcessSession classes which have private access for some properties that contains all information I'm needing.

That classes are located at nifi-framework-core, but once I built my custom processor nar and nifi got started success my custom processor arose a CanntFindClassException. I know the reason is that nifi isolates all dependencies in a nar in order to avoid any conflict.

If someone knows how to solve this trouble or a better solution please let me know.

Regards.

3 REPLIES 3

Re: how to get access to StandardProcessSession and StandardRepositoryContext from a custom processor code?

Custom components have access to an API, not to the implementations. So a processor has access to ProcessSession which is the API, but not StandardProcessSession which is the implementation.

This is done on purpose so that the NiFi framework can evolve behind the scens as long as it adheres to the API which is the contract with the processors/components.

The only way to get the information you are looking for would be to have an upstream processor add attributes to the flow file containing the relevant information, and then use session.getAttribute(...) to get the attributes you are interested in.

Re: how to get access to StandardProcessSession and StandardRepositoryContext from a custom processor code?

New Contributor


Thank you Bryan, the key for this requirement is a loggin problem, we have several LogMessage processors and we are looking for a central processor which handles all messages getting all the information possible; so siteToSiteReportingTask would be a great bet for us. Currently, the trouble we are facing is getting to know how to fetch the incoming connection name IE if a processor fails it will send a fail message through failure relationship, we want to know that record loggin is from that connection.

I'm walking through ExecuteScript path I read this processor could get access for some private props like I'm looking for.

What do you think about it?


Thanks again.


Re: how to get access to StandardProcessSession and StandardRepositoryContext from a custom processor code?

New Contributor

How did you achieved this?. Facing the same issue

Don't have an account?
Coming from Hortonworks? Activate your account here