[
https://issues.apache.org/jira/browse/CAMEL-27112?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen updated CAMEL-27112:
--------------------------------
Description:
FileIdempotentRepository keeps the keys in a file, which makes it the usual
choice for a file or FTP consumer that must not read the same files again after
a restart. It cannot be configured as a bean from properties or from YAML
beans, because its only file setter is setFileStore(java.io.File) and Camel has
no conversion from String to File (IOConverter converts a Path to a File, not a
String):
{noformat}
camel.beans.readFiles =
#class:org.apache.camel.support.processor.idempotent.FileIdempotentRepository
camel.beans.readFiles.fileStore = /var/data/read-files.dat
{noformat}
fails with:
{noformat}
No type converter available to convert from type: java.lang.String to the
required type: java.io.File
{noformat}
The same happens with a YAML bean with properties: fileStore:
/var/data/read-files.dat. The only working form is
camel.beans.readFiles.fileStore =
#class:java.io.File('/var/data/read-files.dat').
Two more paths do not help either:
* Inline in an endpoint parameter,
idempotentRepository=#class:...FileIdempotentRepository#fileIdempotentRepository('/path')
loses the factory method, apparently cut at the #, so the no-argument
constructor runs.
* That constructor leaves fileStore null, and doStart then fails with
"fileStore must be specified" instead of falling back to memory.
Suggestion: add a String setter, such as setFilePath(String) or
setFileStoreName(String), so that the repository can be configured from plain
values. A String to File type converter is not wanted: it would apply to
message bodies as well.
Use case: the FTP and SFTP Kamelets of camel-kamelets could then offer a
persistent idempotent repository bound by the user, instead of re-reading all
files after a restart (apache/camel-kamelets#3170, where "move after read" was
added for now, apache/camel-kamelets#3178).
_Claude Code on behalf of Claus Ibsen_
was:
FileIdempotentRepository keeps the keys in a file, which makes it the usual
choice for a file or FTP consumer that must not read the same files again after
a restart. It cannot be configured as a bean from properties or from YAML
beans, because its only file setter is setFileStore(java.io.File) and Camel has
no conversion from String to File (IOConverter converts a Path to a File, not a
String):
{noformat}
camel.beans.readFiles =
#class:org.apache.camel.support.processor.idempotent.FileIdempotentRepository
camel.beans.readFiles.fileStore = /var/data/read-files.dat
{noformat}
fails with:
{noformat}
No type converter available to convert from type: java.lang.String to the
required type: java.io.File
{noformat}
The same happens with a YAML bean with properties: fileStore:
/var/data/read-files.dat. The only working form is
camel.beans.readFiles.fileStore =
#class:java.io.File('/var/data/read-files.dat').
Two more paths do not help either:
* Inline in an endpoint parameter,
idempotentRepository=#class:...FileIdempotentRepository#fileIdempotentRepository('/path')
loses the factory method, apparently cut at the #, so the no-argument
constructor runs.
* That constructor leaves fileStore null, and doStart then fails with
"fileStore must be specified" instead of falling back to memory.
Suggestion: add a String setter, such as setFilePath(String) or
setFileStoreName(String), so that the repository can be configured from plain
values. A general String to File type converter would also work, but it would
apply to message bodies as well, which is probably why there is none.
Use case: the FTP and SFTP Kamelets of camel-kamelets could then offer a
persistent idempotent repository bound by the user, instead of re-reading all
files after a restart (apache/camel-kamelets#3170, where "move after read" was
added for now, apache/camel-kamelets#3178).
_Claude Code on behalf of Claus Ibsen_
> FileIdempotentRepository cannot be configured from properties or YAML beans:
> fileStore is a File and there is no String setter
> ------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-27112
> URL: https://issues.apache.org/jira/browse/CAMEL-27112
> Project: Camel
> Issue Type: Improvement
> Components: camel-core
> Reporter: Claus Ibsen
> Priority: Major
>
> FileIdempotentRepository keeps the keys in a file, which makes it the usual
> choice for a file or FTP consumer that must not read the same files again
> after a restart. It cannot be configured as a bean from properties or from
> YAML beans, because its only file setter is setFileStore(java.io.File) and
> Camel has no conversion from String to File (IOConverter converts a Path to a
> File, not a String):
> {noformat}
> camel.beans.readFiles =
> #class:org.apache.camel.support.processor.idempotent.FileIdempotentRepository
> camel.beans.readFiles.fileStore = /var/data/read-files.dat
> {noformat}
> fails with:
> {noformat}
> No type converter available to convert from type: java.lang.String to the
> required type: java.io.File
> {noformat}
> The same happens with a YAML bean with properties: fileStore:
> /var/data/read-files.dat. The only working form is
> camel.beans.readFiles.fileStore =
> #class:java.io.File('/var/data/read-files.dat').
> Two more paths do not help either:
> * Inline in an endpoint parameter,
> idempotentRepository=#class:...FileIdempotentRepository#fileIdempotentRepository('/path')
> loses the factory method, apparently cut at the #, so the no-argument
> constructor runs.
> * That constructor leaves fileStore null, and doStart then fails with
> "fileStore must be specified" instead of falling back to memory.
> Suggestion: add a String setter, such as setFilePath(String) or
> setFileStoreName(String), so that the repository can be configured from plain
> values. A String to File type converter is not wanted: it would apply to
> message bodies as well.
> Use case: the FTP and SFTP Kamelets of camel-kamelets could then offer a
> persistent idempotent repository bound by the user, instead of re-reading all
> files after a restart (apache/camel-kamelets#3170, where "move after read"
> was added for now, apache/camel-kamelets#3178).
> _Claude Code on behalf of Claus Ibsen_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)