Search code examples
apache-nifi

Apache NiFi - Storing and Access to dynamic data


I am a beginner in Apache NiFi and am trying to find the best way to do the following process.

I have an API that exposes an endpoint that provides me a token for the next requests (available for a few hours). I want to store this token for general purposes because I need other flows accessing this token.

I would prefer not to use Files or external Databases, so I was wondering about using variables, but honestly, I don't know if this is the best way.

So far, I know how to connect with the API (i.e. InvokeHTTP), and get the token (EvaluateJsonPath), but I don't know how to store and where (Variable?) and how to use it in another flow.

Current flow so far:

Store Token: GenerateFlowFile -> InvokeHTTP -> EvaluateJsonPath -> ??

New request using the token: GenerateFlowFile -> InvokeHTTP (Here I need to access the token)

Can anyone help me?


Solution

  • You could look into using the DistributedMapCache controller service.

    The flow would be something like:

    GenerateFlowFile -> InvokeHTTP -> EvaluateJsonPath -> PutDistributedMapCache

    GenerateFlowFile -> FetchDistributedMapCache -> InvokeHTTP