Support Questions

Find answers, ask questions, and share your expertise

Schedule Invoking HTTP dynamically - Nifi

avatar
Explorer

Is there any way which we can pass dynamic CRON expression as a run schedule input to invoke HTTP processor (using NiFi 1.19.1).

Because I have CRON expression which is stored in DB. Where I am fetching it through ( executesql -> convertAvroToJson -> SplitJson -> Evaluate JsonPath (schedule: $.schedule)).

If I add ${schedule} in invoke HTTP processor getting Unexpected character error.

Looking for expert's help @MattWho @SAMSAL @cotopaul 

 

1 ACCEPTED SOLUTION

avatar
Master Collaborator

This is not possible since Scheduling Strategy can not be set dynamically or via any attribute (flow or variable )

Thank You

View solution in original post

3 REPLIES 3

avatar
Master Collaborator

This is not possible since Scheduling Strategy can not be set dynamically or via any attribute (flow or variable )

Thank You

avatar
Explorer

@ckumar Thanks.. I have CRON schedule from DB, based on that CRON i need to do certain API calls.

Is there any other way to achieve?

avatar
Master Mentor

@Vikas-Nifi 

@ckumar is 100% correct.  Only fields explicitly marked as supporting NiFi Expression Language (NEL) can support a NEL expression "${schedule}".

I am however curious about your use case as to why you would even being trying to do this.  From what you shared you are extracting a cron schedule from the json content of some FlowFiles traversing an EvaluateJsonPath processor.  That "schedule" is added on to the NiFi FlowFile as a FlowFile attribute (key=value pair).   This would not make that key=value pair accessible to any other NiFi component unless that FlowFile containing the FlowFile attribute was processed by that other component.   However, in your shared dataflow you do not mention that EvaluateJsonPath connects to your invokeHTTP processor via an inbound dataflow connection (Keep in mind that even if you did do this, it does not change the fact that the run schedule property does not support NEL).   I just wanted to clarify how FlowFile attributes are and can be used.

Also keep in mind that the "run schedule" is a scheduler only.  The run schedule set on a processor controls when the NiFi controller will schedule the execution of the processors code.  It does not mean that they the processor will immediately execute at time of scheduling (It may be delayed on execution waiting for an available execution thread from the thread pool).  All scheduled components share a thread pool and NiFi framework will also handle assigning threads to next scheduled component as thread become available.  So the NiFi framework needs to know the scheduling for a component when it is started; otherwise, NiFi would never know when to schedule it to execute.  

Unless a component property has an explicit tool tip that tells you it support NEL, then it does not.  For NiFi processor components, you will find that only some processor specific properties within the "PROPERTIES" tab support NEL.  This is not only available through property tooltips, but also in the processors documentation.
Examples:

MattWho_0-1717074788049.png

MattWho_1-1717074848934.png

Even when NEL is supported there is a scope.  It may support FlowFile attributes, Variable Registry (going away in NiFi 2.x releases), or both. 

Thank you, 
Matt