pfx-sftp

Summary: Reference for the pfx-sftp Camel component — secure file transfer for uploading/downloading integration files.


Overview

The pfx-sftp component extends the standard Apache Camel SFTP component (SftpComponent) with Pricefx connection management. It allows routes to reference a named SFTP connection configured in Integration Manager, automatically resolving host, port, path, credentials, and host-key checking settings.

The component is registered under the scheme pfx-sftp and belongs to the FILE category.

When to Use

Scenario

Description

Upload export files

Push files generated by Pricefx (price lists, quotes, etc.) to an external SFTP server for downstream consumption.

Download import files

Pull files from an SFTP server to feed into Pricefx data loads (products, customers, price data).

Poll for new files

Continuously monitor an SFTP directory for new files arriving from external systems, triggering import routes automatically.

URI Format

pfx-sftp://[user@]host[:port]/directoryName[?options]

When a connection parameter is provided, the host, port, path, username, password, and strictHostKeyChecking values are resolved from the named SFTP connection. Any directory specified in the URI is appended to the connection's base path.

If no connection is specified, the URI behaves like the standard Camel sftp component and all parameters must be provided inline or via query options.

Connection Fields

SFTP connections are configured in Integration Manager with the following fields (defined in SFTPConnection):

Field

Type

Default

Description

host

String

(required)

Address of the SFTP server

port

int

22

Port the SFTP server listens on

path

String

/

Starting access point (base directory) for the connection

username

String

(optional)

Username for authentication

password

String

(optional)

Password for authentication (encrypted at rest)

strictHostKeyChecking

boolean

false

Whether host keys are verified during connection. Disabled by default.

Connections also support certificate-based authentication. When a certificateName is set on the connection, the corresponding private key is injected into the SFTP configuration.

Endpoint Parameters

The pfx-sftp endpoint inherits all parameters from the Camel SftpEndpoint. The following parameter is added by the Pricefx wrapper:

Parameter

Type

Description

connection

String

Name of the SFTP connection to use. When set, host, port, path, username, password, and strictHostKeyChecking are resolved from the connection.

All standard Camel SFTP parameters remain available (e.g., fileName, delete, moveFailed, tempPrefix, recursive, noop, readLock, delay, etc.). See the Apache Camel SFTP documentation for the full list.

URI Resolution Logic

When connection is specified:

  1. The connection is looked up from the Integration Manager connection registry.

  2. Protocol is set to sftp.

  3. Host, port, and strictHostKeyChecking are applied from the connection.

  4. Directory resolution:

    • If no directory is specified in the URI, the connection's path is used.

    • If a directory is specified and differs from the default, it is appended to the connection's path (e.g., connection path /data + URI directory exports = /data/exports).

  5. Username and password are applied if present on the connection.

  6. A private key is injected if the connection has a certificateName.

Usage Examples

Download with named connection

XML
<route id="sftpDownload">
    <from uri="pfx-sftp://dummy?connection=my-sftp-conn&amp;noop=true&amp;fileName=data.csv"/>
    <to uri="direct:processFile"/>
</route>

The dummy host is overridden by the connection's host. The noop=true option leaves the file on the server after reading.

Upload with named connection

XML
<route id="sftpUpload">
    <from uri="direct:uploadFile"/>
    <to uri="pfx-sftp://dummy/outbound?connection=my-sftp-conn&amp;tempPrefix=.uploading"/>
</route>

Files are uploaded to the outbound subdirectory relative to the connection's base path, using a temporary prefix during transfer.

Inline credentials (no connection)

XML
<route id="sftpInline">
    <from uri="pfx-sftp://{{sftp.username}}@{{sftp.host}}:22/data/inbound?password={{sftp.password}}&amp;strictHostKeyChecking=no"/>
    <to uri="direct:processFile"/>
</route>

When no connection parameter is provided, credentials and host details must be specified in the URI directly. This approach is functionally equivalent to the standard Camel sftp component.

Poll with delay and move

XML
<route id="sftpPoll">
    <from uri="pfx-sftp://dummy/inbound?connection=my-sftp-conn&amp;delay=30000&amp;move=.done"/>
    <to uri="direct:processFile"/>
</route>

Polls the inbound directory every 30 seconds and moves processed files to .done.

Connection Testing

The SFTPConnection.test() method opens an SFTP channel to verify connectivity. It connects using the configured host, port, username, password, and strictHostKeyChecking setting, then validates the configured path exists on the server.

Error Handling

  • If a named connection cannot be found, a NonRecoverableException is thrown at route startup with the message: Cannot find SftpConnection with name: [<name>].

  • Standard Camel SFTP error handling applies for file-level operations (read locks, permission errors, network failures).

Common Pitfalls

Pitfall

Recommendation

Hardcoding credentials in route XML

Always use a named connection and store credentials in the Integration Manager connection configuration. This keeps secrets encrypted at rest and out of version control.

Leaving strictHostKeyChecking disabled in production

The default is false for convenience during development. In production, enable it and ensure the server's host key is trusted to prevent man-in-the-middle attacks.

Path resolution confusion

Remember that a URI directory is appended to the connection's base path. If the connection path is /data and the URI directory is exports, the effective path is /data/exports, not /exports.

Missing tempPrefix on uploads

Without a temporary prefix, downstream systems may pick up partially written files. Use tempPrefix=.uploading or similar.

See Also