davsclaus opened a new pull request, #31363:
URL: https://github.com/apache/camel/pull/31363

   _Claude Code on behalf of Claus Ibsen (davsclaus)_
   
   [CAMEL-28111](https://issues.apache.org/jira/browse/CAMEL-28111)
   
   ## Problem
   
   Some components evaluate an endpoint option as an expression for each 
message, for example the meter name and the `tags.` options of 
`camel-micrometer`, the `keyName` and the bucket of `camel-aws2-s3`, the 
`parameters.` of `camel-jpa`, or the `fileName` / `move` / `filterFile` options 
of the file components. With a static `to` the route author writes 
`micrometer:counter:orders?tags.region=${header.region}` and the component 
resolves `${header.region}` against each message.
   
   With a dynamic uri (`toD`, `enrich` / `pollEnrich` with an expression, 
`wireTap` with a dynamic uri) the whole uri is evaluated before the endpoint is 
created, so the component receives the resolved header value as the option text 
instead of the template, and then parses that header value as an expression of 
its own. A header value that contains `${...}` is therefore not used as given, 
and the same route behaves differently with `to` and with `toD`. Only the file 
components restored their template text, and only through `SendDynamicAware` 
(not with `allowOptimisedComponents=false`, and for `pollEnrich` only 
`fileName`).
   
   ## Change
   
   - `camel-api`: `EndpointUriFactory` gets two default methods, 
`expressionPropertyNames()` (the options the endpoint evaluates as an 
expression, multi-value options by their prefix such as `tags.`) and 
`expressionPathSyntax()` (the syntax of the path, such as 
`:metricsType:metricsName`, when a path option is one of them).
   - `camel-package-maven-plugin`: the uri factory of each component generates 
them from the existing `supportSimpleExpression` metadata. `Expression` / 
`Predicate` typed options are left out, as they are bean references and not 
evaluated text. Only the factories of components with such options change.
   - `camel-core-processor`: new `DynamicUriTemplate`, used by 
`SendDynamicProcessor` (`toD`, `enrich`, dynamic `wireTap`) and `PollEnricher`. 
When the endpoint has expression options, they keep the text of the uri as 
written in the route, so the component evaluates it once against the message, 
as with a static `to`. For a component with an expression path option (these 
are producer options), the path segments of those options are kept as written, 
except with `pollEnrich`; the other path segments, such as the meter type of 
`micrometer:${header.type}:orders`, are computed from the message as before. An 
expression option that is not in the uri as written (it only appears in the 
computed uri, for example because a header value contains `&`) is rejected with 
a `ResolveEndpointFailedException`. This does not depend on 
`allowOptimisedComponents`. Other options still resolve their `${header.x}` as 
before. `recipientList`, `routingSlip` and `dynamicRouter` are not changed.
   - Metadata: `supportSimpleExpression` added where the option is evaluated 
per message but was not marked: `camel-aws2-s3` `keyName`, 
`destinationBucketPrefix`, `destinationBucketSuffix`; `camel-jpa` `parameters`; 
`camel-openfga` `user`, `object`, `relation`, `contextualTuples`, 
`continuationToken`; `camel-typesafe-ai` `state`; the file components `sortBy`; 
`camel-google-storage` `downloadFileName`.
   - `camel-file`: `GenericFilePollDynamicAware` keeps the uri text of the same 
consumer expression options, not only `fileName`.
   - `camel-aws2-s3`: the endpoint skips the startup bucket check when the 
bucket name is a Simple expression (the producer resolves it for each message), 
so `aws2-s3://${header.bucket}` can start.
   - Upgrade guide 4.25 entry.
   - Regenerated `src/generated` and the catalog.
   
   ## Tests
   
   - `ToDynamicExpressionOptionTest` (camel-core): a test component with the 
path `kind:path` that evaluates the `path` segment, an option and `tags.` per 
message (not the `kind`), through `toD`, `toD` without optimisation, `enrich` 
and `wireTap`; header text with `${...}` reaches the component as given, plain 
header values still resolve, one endpoint is used for all messages, and an 
expression option that is only in the computed uri is rejected.
   - `PollEnrichFileExpressionOptionTest` (camel-core): `pollEnrich` with 
`filterFile` from a header, and rejection of an option that is only in the 
computed uri.
   - `MicrometerToDynamicTagTest` (camel-micrometer): tag value and meter name 
equal the header text, and the meter type can come from a header 
(`micrometer:${header.type}:orders.${header.region}`).
   - `AWS2S3ToDynamicKeyNameTest` (camel-aws2-s3): key and bucket equal the 
header text, and the bucket is not checked at startup.
   
   - `PollDynamicFileNameOptimizeDisabledTest` (camel-core) now expects one 
file endpoint, as `fileName` keeps the uri text also when 
`allowOptimisedComponents` is false.
   
   The new tests fail without the change in `camel-core-processor` (and 
`camel-aws2-s3` / `camel-file`), and pass with it.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to