pfx-api:loaddataFile

pfx-api:loaddataFile

Load data from a file into Pricefx with support for batching, compression, and wait-for-completion strategies.


Overview

The loaddataFile method is a variant of loaddata designed for file-based imports. It reads data from a file (the exchange body or a file endpoint), applies a mapper, and bulk-loads it into Pricefx. It adds support for:

  • Wait-for-completion strategies -- wait for the server to finish processing before continuing the route

  • Batch tracking -- reports total records, failed records, and failed batches via exchange headers

  • File compression -- handles compressed input files

URI Format

pfx-api:loaddataFile?objectType=P&mapper=productMapper&businessKeys=sku&waitForCompletionStrategy=Always

Parameters

All parameters from loaddata are supported, plus:

Parameter

Type

Default

Description

waitForCompletionStrategy

WaitForCompletionStrategy

Never

Controls whether the route waits for the server to finish processing. See below.

waitForCompletionStrategy Values

Value

Behavior

Never

Fire and forget. The route continues immediately after the file is uploaded. No completion check is performed.

Always

Wait until the server reports completion. If the server reports a failure, an exception is thrown and the route stops.

AlwaysAndIgnoreFailures

Wait until the server reports completion, but continue the route even if failures are reported. Failed record counts are available in headers.


Staging

When using loaddataFile, the file is uploaded to the Pricefx staging area and then processed server-side. This means:

  • The file is transferred in a single upload

  • Server-side processing handles batching internally

  • You do not need to manually batch the data


Examples

Basic File Load

XML
<route>
    <from uri="file:input/products?noop=true"/>
    <to uri="pfx-api:loaddataFile?objectType=P&amp;mapper=productMapper&amp;businessKeys=sku"/>
</route>

File Load with Wait-for-Completion

XML
<route>
    <from uri="file:input/data?noop=true"/>
    <to uri="pfx-api:loaddataFile?objectType=P&amp;mapper=productMapper&amp;businessKeys=sku&amp;waitForCompletionStrategy=Always"/>
    <log message="Load completed. Total records: ${header.PfxTotalInputRecordsCount}, Failed: ${header.PfxTotalFailedInputRecordsCount}"/>
</route>

File Load Ignoring Failures

XML
<route>
    <from uri="file:input/data?noop=true"/>
    <to uri="pfx-api:loaddataFile?objectType=P&amp;mapper=productMapper&amp;businessKeys=sku&amp;waitForCompletionStrategy=AlwaysAndIgnoreFailures"/>
    <choice>
        <when>
            <simple>${header.PfxTotalFailedInputRecordsCount} > 0</simple>
            <log message="WARNING: ${header.PfxTotalFailedInputRecordsCount} records failed"/>
        </when>
    </choice>
</route>

Load Data Source from File

XML
<route>
    <from uri="file:input/datasource?noop=true"/>
    <to uri="pfx-api:loaddataFile?objectType=DMDS&amp;dsUniqueName=MyDataSource&amp;mapper=dsMapper&amp;businessKeys=sku,region&amp;waitForCompletionStrategy=Always"/>
    <to uri="pfx-api:flush?dataFeedName=MyFeed&amp;dataSourceName=MyDataSource"/>
</route>

Headers Produced

Header

Type

Description

PfxTotalInputRecordsCount

Integer

Total input records processed across all batches.

PfxTotalFailedInputRecordsCount

Integer

Total failed input records.

PfxFailedBatchesCount

Integer

Number of failed batches.


Common Pitfalls

  1. Using Never and expecting completion -- With waitForCompletionStrategy=Never, the route continues immediately. If you need to flush or run subsequent steps that depend on the data being loaded, use Always.

  2. Not checking failure headers -- When using AlwaysAndIgnoreFailures, always check PfxTotalFailedInputRecordsCount to detect partial failures. Silent data loss is a common issue.

  3. Forgetting flush after DMDS load -- Just like loaddata, if you load into a Data Source you must call pfx-api:flush afterward.

  4. File format issues -- Ensure the file format (CSV, etc.) matches what the mapper expects. Mismatched delimiters or encodings will cause silent data corruption or load failures.

  5. Large file timeouts -- For very large files, the server-side processing may take a long time. If using Always, ensure your route timeout is sufficient to cover the processing time.