Jsch

Overview

The Jsch component provides scp-based endpoints for copying files to a remote file system. It supports the SCP protocol using the Client API of the Jsch project.

Dependencies

Maven users will need to add a dependency on camel-jsch to their pom.xml for this component:

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-jsch</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>

URI format

The URI format for a jsch scp endpoint is:

scp://host[:port]/destination[?options]

You can append query options to the URI in the following format: ?option=value&option=value&....

You can specify the filename either in the <path> part of the URI or as a CamelFileName header on the message (Exchange.FILE_NAME if used in code).

Options

Table 57, “scp endpoint options” lists the options for an HTTP endpoint.

Table 57. scp endpoint options

NameDefaultDescription
username null Specifies the user name to use to log into the remote file system.
password null Specifies the password to use to log into the remote file system.
knownHostsFile null Sets the known_hosts file so that the scp endpoint can perform host key verification.
strictHostKeyChecking no Specifies whether to use strict host key checking.
chmod null Enables you to set chmod on the specified stored file; for example, chmod=664.

Limitations

Currently, the Jsch component supports only a producer, that is it can only copy files to a remote host. This is so because the SCP protocol does not provide the capability to scan (list) the contents of a directory. So a polling consumer cannot watch for changes and trigger events on them.

However, it is possible to use the Jsch component in sink mode for a one-time copy from a remote host using a ConsumerTemplate (see File). If your application requires secure transfers or continuous monitoring of a directory on a remote host, use the sftp protocol instead (see File).

Related topics

FTP/SFTP