Claus Ibsen created CAMEL-25792:
-----------------------------------

             Summary: camel-file - poll and pollEnrich evaluate a fileName that 
does not use the file functions on the current exchange, so ${body} works
                 Key: CAMEL-25792
                 URL: https://issues.apache.org/jira/browse/CAMEL-25792
             Project: Camel
          Issue Type: Bug
          Components: camel-ftp, camel-file
            Reporter: Claus Ibsen
            Assignee: Claus Ibsen
             Fix For: 4.24.0


poll and pollEnrich with a file based endpoint evaluate the {{fileName}} option 
for each file they find, on an exchange whose body is that file. So 
{{fileName=${body[customer]}.json}} or {{fileName=${body}}} does not read the 
incoming message, which is what people write and what the docs promise 
("dynamic uris computed based on information from the current Exchange").

What happens today:
# Since CAMEL-21733 (4.11) poll and pollEnrich reuse endpoints: 
{{GenericFilePollDynamicAware}} keeps {{fileName}} unevaluated in one static 
endpoint uri.
# The consumer evaluates {{fileName}} in {{GenericFileConsumer.isMatched}} for 
each file it finds, on a dummy exchange: the body is the file being checked, 
with its {{CamelFile*}} headers, and the headers, variables and exchange 
properties of the incoming message copied in.
# So {{${body[customer]}}} reads a {{java.io.File}}: "Key: customer not found 
in bean: .../customers/C-482.json of type: java.io.File", for every file on 
every poll, until the timeout. A header or a variable works; the body does not.

In a benchmark of Oct 18-19 2026 (a local model building an enrich-and-dedupe 
example), the pollEnrich step failed in 8 of 8 runs on this, with 500 to 2,300 
such log lines per run.

The fix (decided with Claus, Oct 19): an expression that uses the file 
functions ({{${file:...}}}, {{${date:file:...}}}) is about the consumed file, 
and is evaluated per file as today; any other expression is evaluated on (a 
copy of) the current exchange. Endpoint reuse stays. This covers every file 
based component with the poll optimisation: file, ftp, ftps, sftp, smb and 
azure-files, which share {{GenericFileConsumer}}.

To note in the upgrade guide: {{${body}}} in the {{fileName}} of poll or 
pollEnrich is now the incoming body, not the file.

_Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to