ramu11 commented on code in PR #27686:
URL: https://github.com/apache/camel/pull/27686#discussion_r4241881387
##########
components/camel-kamelet/src/main/java/org/apache/camel/component/kamelet/Kamelet.java:
##########
@@ -230,6 +232,63 @@ public static RouteDefinition
templateToRoute(RouteTemplateDefinition in, Map<St
throw new IllegalArgumentException("Camel route " + rid + " input
does not exist.");
}
+ // Extract advanced options for source/sink component endpoints
+ Map<String, Object> sourceOptions =
PropertiesHelper.extractProperties(parameters, "source.");
+ Map<String, Object> sinkOptions =
PropertiesHelper.extractProperties(parameters, "sink.");
+
+ // Determine Kamelet type: source Kamelets have real component as
input,
+ // sink/action Kamelets have kamelet:source as input and real
component in outputs
+ boolean isSourceKamelet =
!def.getInput().getEndpointUri().startsWith("kamelet:source")
+ &&
!def.getInput().getEndpointUri().startsWith("kamelet://source");
+
+ if (isSourceKamelet) {
+ // Source Kamelet: real component endpoint is the input
+ if (!sourceOptions.isEmpty()) {
+ try {
+ String newUri =
URISupport.appendParametersToURI(def.getInput().getUri(), sourceOptions);
+ def.getInput().setUri(newUri);
+ } catch (Exception e) {
+ throw new IllegalArgumentException(
+ "Failed to apply advanced source options to
endpoint URI: " + def.getInput().getUri(), e);
+ }
+ }
+ if (!sinkOptions.isEmpty()) {
+ throw new IllegalArgumentException(
+ "sink.* advanced options are not valid for source
Kamelets (input is '"
+ +
def.getInput().getEndpointUri() + "'). Use source.* options instead.");
+ }
+ } else {
+ // Sink/Action Kamelet: real component endpoint(s) are in outputs
+ if (!sourceOptions.isEmpty()) {
+ throw new IllegalArgumentException(
+ "source.* advanced options are not valid for
sink/action Kamelets (input is '"
+ +
def.getInput().getEndpointUri() + "'). Use sink.* options instead.");
+ }
+ if (!sinkOptions.isEmpty()) {
+ Collection<ToDefinition> outputs =
filterTypeInOutputs(def.getOutputs(), ToDefinition.class);
Review Comment:
Thanks for catching this. I've updated the handling to distinguish static
`to()` outputs from dynamic `toD()` outputs. Sink options are applied to static
endpoints only, while dynamic endpoints are left unchanged. If sink options are
supplied but the Kamelet has only dynamic outputs, startup now fails with a
clear error message instead of silently skipping them.
--
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]