Understanding Functions in Clockspring

Modified on Thu, 11 Dec, 2025 at 9:08 PM

Functions in Clockspring let you create reusable workflows that can be called from multiple places in a flow. This improves modularity and reduces duplicated logic across the system.

A Function is built using three processors and a controller service:

  • BeginFunction – Defines the entry point

  • EndFunction (optional) – Returns data to the caller

  • ExecuteFunction – Calls the Function

  • FunctionCoordinatorService – Handles routing between these processors


How Functions Work

A Function is a self-contained mini-workflow. It can return data back to the caller or simply perform a task and end.

1. Defining a Function

Inside a Process Group:

  1. Add BeginFunction and assign a Function Name

  2. Add your logic behind it

  3. Add EndFunction if you want to return FlowFiles

If you don’t need a return (example: logging tasks), you can skip EndFunction and the FlowFiles terminate inside the Function.

2. Calling a Function

Use ExecuteFunction:

  • The FunctionCoordinatorService routes FlowFiles from ExecuteFunction → BeginFunction

  • If an EndFunction exists, the FlowFile is returned back to the calling ExecuteFunction

  • If not, the FlowFile ends inside the Function

This creates clean, reusable logic without manual wiring.


Setting Up a Function

1. Configure FunctionCoordinatorService

All Function processors must reference the same Coordinator.


It manages:

  • Function registration

  • Routing requests

  • Returning results

2. Build the Function Process Group

BeginFunction → (Your Logic) → EndFunction (optional)

3. Call the Function

Configure ExecuteFunction with:

  • Function Name

  • Coordinator Service


Example: Non-return Function (Error Logging) 

Inside the Function process group:

  • BeginFunction named log_errors

  • LogAttributes

  • PutFile to write the log data

There is no EndFunction, so FlowFiles stop inside this Function.

Calling it from another flow

RouteOnAttribute (matching your error condition) connects into ExecuteFunction set to log_errors.


Example: Returning Function (Data Normalization)

Inside the Function process group:

  • BeginFunction named normalize_data

  • UpdateRecord (apply your normalization logic)

  • EndFunction to return the processed FlowFile


Calling it from another flow

ExecuteFunction set to normalize_data sends the FlowFile into the Function and receives a processed FlowFile back, which you can then connect to PutDatabaseRecord or any other processor.


Performance Note

Using Functions introduces some overhead:

  • FlowFiles leave the main process group

  • They move through the FunctionCoordinatorService

  • They return back to the caller (if EndFunction exists)

Because of this additional routing and coordination, Functions have lower throughput compared to building the same logic directly in a standard process group. They are best used when modularity or reuse is more important than raw throughput.


Key Takeaways

  • Functions make Clockspring flows reusable and easier to maintain

  • BeginFunction defines the start

  • EndFunction returns data (optional)

  • ExecuteFunction calls the Function

  • FunctionCoordinatorService handles routing

  • Throughput is lower than direct connections due to coordination overhead

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article