Common Attribute Patterns

Modified on Thu, 11 Dec, 2025 at 12:03 PM

Summary

Many Clockspring flows rely on recurring attribute patterns for routing, API calls, filenames, deduplication, error handling, and coordinating multi-step workflows. These patterns make flows predictable, maintainable, and environment-agnostic.


1. Correlation IDs

Use a correlation ID to track a FlowFile across processors, retries, and external systems.


Pattern:
Set once at the start of the flow:

correlation.id = ${uuid()}


Include it in logs, API headers, and downstream processors.
It becomes your primary debugging anchor.


2. Extracting keys from content for later use

When content will be overwritten (API calls, record transformations, merges), extract the fields you need to preserve.


Common extracted attributes:

  • customer.id

  • order.id

  • event.timestamp

  • next.page.token


These attributes carry critical context even when the content changes entirely.


3. Constructing API endpoints dynamically

Attributes often determine which resource an API call targets.


Pattern:

#{base_url}/api/customers/${customer.id}
  • #{base_url} = parameter (environment-specific)

  • ${customer.id} = attribute (FlowFile-specific)


This ensures the same flow works across Dev/Test/Prod while still acting on per-record values.


4. Building filenames and paths

Attributes help build meaningful, traceable file names and storage paths.


Examples:

${customer.id}_${event.timestamp}.json ${filename:replace('.csv','.json')} #{output_root}/${customer.id}/${filename}


Use attributes for uniqueness and traceability; use parameters for environment-specific paths.


5. Routing decisions

Most routing logic comes from attributes.


Examples:

  • ${record.count:gt(0)} → has data

  • ${mime.type:contains("json")} → JSON path

  • ${color:equals("blue")} → Blue path


Small, predictable attributes drive clean flow branching.


6. Deduplication keys

DetectDuplicate and cache-based logic require stable, deterministic keys.


Common patterns:

  • ${sha256}

  • ${customer.id}:${event.timestamp}

  • ${record.id}


Good dedup keys survive retries and replays.


7. Pagination and resume tokens

APIs often return tokens or cursors for retrieving subsequent pages.


Extract and store:

  • next.page.token

  • next.offset

  • next.cursor


These attributes drive iterative InvokeHTTP calls or loops.


8. Retry counters

When implementing custom retry logic, increment a counter on each attempt.


Example:

retry.count = ${retry.count:plus(1)}

Use routing to stop retrying if it exceeds a threshold.


9. Audit attributes

Add lightweight metadata to FlowFiles for traceability.


Common audit attributes:

  • source.system

  • flow.name

  • processed.timestamp

  • last.updated.by


These values simplify troubleshooting and operational review.


10. Mixing parameters and attributes in the same property

In real flows, you often combine environment-level parameters with FlowFile-level attributes.

Pattern:

#{base_url}/api/customers/${customer.id}
  • #{} = parameters (Dev/Test/Prod differences)

  • ${} = attributes (the specific values from the FlowFile)

More examples:

#{output_root}/${account.id}/${filename} SELECT * FROM #{schema}.orders WHERE id = ${order.id} Authorization: Basic #{api_basic_auth}

Why this works:

  • Flows stay environment-independent

  • Logic stays tied to the FlowFile

  • URLs, queries, and paths stay flexible and maintainable

Rule:
Parameters define the environment.
Attributes define the FlowFile.
Use both if you need dynamic behavior.


Related Articles

  • FlowFile Content vs Attributes

  • How Attributes Move Through a Flow

  • Expression Language Basics

  • Best Practices for Attributes

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