SMB Source
Provided by: "Apache Software Foundation"
Support Level for this Kamelet is: "Stable"
Reads the files in a directory of a Windows or Samba file share (SMB), one message per file, and by default leaves them on the share.
Use it to collect the files that another system drops on a Windows file server or a NAS, such as orders, invoices or exports, from a share such as \\fileserver\exports. To write files to a share use smb-sink. For an FTP or SFTP server use ftp-source or sftp-source.
Output: the body is the content of the file, as bytes, or as a stream when streamDownload is true. Content-Type is application/octet-stream. The file and ce-file headers hold the name of the file, with its path below directoryName when recursive is true, such as 2026/orders.csv. CamelFileName holds the same name, CamelFileLength the size of the file in bytes, CamelFileLastModified the time the file was last changed, in milliseconds since 1970, and CamelSmbUncPath the full Windows path of the file, such as \\fileserver\exports\orders\orders.csv.
Good to know: files are not deleted or moved after they are read, unless delete is true or move is set. A file is read only once while the integration runs (idempotent), but the files left on the share are all read again after a restart; to read each file only once, also across restarts, set move to a directory such as .done, set delete to true, or keep the list of the files read in a file with idempotentRepository. To read only some of the files, set include, exclude or antInclude. To leave a file alone while another program is still writing it, set readLock. Log in with username and password, or, on a share that allows guest access, with username set to Guest and no password. When the server cannot be reached or the login fails, the poll is skipped with a warning in the log, and tried again at the next poll. The content of the files is not encrypted on the network unless encryptData is true, and a share that requires encryption refuses the connection without it. When the application has a bean of the type com.hierynomus.smbj.SmbConfig, Camel uses it for the connection, and the Kamelet then fails to start when encryptData is true, or connectTimeout, readTimeout or transactTimeout is set: set them on that bean instead.
Configuration Options
The following table summarizes the configuration options available for the smb-source Kamelet:
| Property | Name | Description | Type | Default | Example |
|---|---|---|---|---|---|
Connection Host | Required The host name or IP address of the SMB server, without | string | fileserver.example.com | ||
Share Name | Required The name of the share, as the server shares it, such as | string | exports | ||
Username | Required The user to log in to the SMB server as, without the domain, such as | string | |||
Include Files (Wildcards) | Wildcard patterns, separated by commas, that the path of a file must match to be read, such as | string | */.csv | ||
Autocreate Missing Directories | If true, | boolean | true | ||
Connect Timeout | How long to wait for the connection to the server, in milliseconds. When it is not set, 5000 (5 seconds). | integer | 10000 | ||
Connection Port | The port of the SMB server, usually 445. | integer | 445 | ||
Poll Interval | How long to wait between two polls of the directory, in milliseconds. For example, 60000 polls once a minute. When it is not set, 500. | integer | 60000 | ||
Delete | If true, each file is deleted from the share once it has been read and handed on successfully. Use it to read each file only once, also across restarts. To keep the files, set | boolean | false | ||
Directory Name | The directory within the share to read the files from, with | string | outgoing/orders | ||
Domain | The Windows domain of | string | CORP | ||
Encrypt Data | If true, everything sent to and from the server, the content of the files included, is encrypted (SMB 3 encryption), also on a share that does not require it. A share that requires encryption, such as one with | boolean | false | ||
Exclude Files | A regular expression for the names of the files not to read, such as | string | .*\.(tmp|part) | ||
Skip Files Already Read | If true, a file is read only once while the integration runs, even when it stays on the share. The list of the files read is kept in memory, so after a restart the files still on the share are read again, unless | boolean | true | ||
Files Read Store | The name of a bean that keeps the list of the files read, so that the files left on the share are not read again after a restart, such as a | string | readFiles | ||
Include Files | A regular expression that the name of a file must match to be read, such as | string | .*\.csv | ||
Max Files Per Poll | The largest number of files to read in one poll, such as 100. The other files are read at the next polls. The poll takes the first files the server lists, and | integer | 100 | ||
Move After Read | Where to move each file on the share once it has been read and handed on successfully, so that it is not read again, also after a restart. A directory name, such as | string | .done | ||
Move Failed Files To | Where to move a file on the share when it could not be handed on, for example because the next step failed, so that it is not read over and over. The same format as | string | .error | ||
Password | The password of | string | |||
Move Before Read | Where to move each file on the share before it is read, so that another reader of the same directory does not take it too. The same format as | string | .inprogress | ||
Wait Until Written | How to make sure that another program has finished writing a file before it is read. Enum values: * none * changed * rename | string | changed | ||
Minimum File Age | Only used when | integer | 60000 | ||
Read Timeout | How long to wait for the server to answer a read of the content of a file, in milliseconds. When it is not set, 60000 (1 minute). | integer | 120000 | ||
Recursive | If true, the files in the subdirectories of | boolean | false | ||
Sort By | The order in which the files of a poll are read. | string | reverse:file:modified | ||
Stream Download | If true, each file is read from the share while it is handed on, instead of being read into memory first, and the body is a stream. Use it for files too large for memory. It saves memory only when the integration does not keep the stream in memory either: set | boolean | |||
Request Timeout | How long to wait for the server to answer the other requests, such as listing a directory, or opening, renaming or deleting a file, in milliseconds. When it is not set, 60000 (1 minute). | integer | 30000 |
Dependencies
At runtime, the smb-source Kamelet relies upon the presence of the following dependencies:
-
camel:smb
-
camel:kamelet
Camel JBang usage
Prerequisites
-
You’ve installed JBang.
-
You have executed the following command:
jbang app install camel@apache/camel Supposing you have a file named route.yaml with this content:
- route:
from:
uri: "kamelet:smb-source"
parameters:
.
.
.
steps:
- to:
uri: "kamelet:log-sink" You can now run it directly through the following command
camel run route.yaml