Hi Babak,

Thank you for fixing the reported problem. We will track this JIRA and PR.
But I see the title of your JIRA ticket is related to URI placeholder, but I 
have reported problem with .id() placeholder.
So id placeholder should be fixed. If anything is left unclear, be free to ask 
me, so we can make it more clear.

Kind Regards,
Nikola Glidzic
From: Nikola Glidzic
Sent: Monday, December 12, 2022 1:24 PM
To: users@camel.apache.org
Subject: RE: BUG - missing configuration placeholder possibility for id in REST 
DSL

Sorry guys, I didn't know image can't be sent. Combine this email with previous 
one. Here is the relevant part of code of method forceAssignIds(), mentioned 
lines are marked with arrows:

public static void forceAssignIds(CamelContext context, List<RouteDefinition> 
routes) throws Exception {
        ExtendedCamelContext ecc = context.adapt(ExtendedCamelContext.class);

        // handle custom assigned id's first, and then afterwards assign auto
        // generated ids
        Set<String> customIds = new HashSet<>();

        for (final RouteDefinition route : routes) {
            // if there was a custom id assigned, then make sure to support
            // property placeholders
            if (route.hasCustomIdAssigned()) {
                final String originalId = route.getId();
                final String id = 
context.resolvePropertyPlaceholders(originalId);                                
                                                                          <- 
line 142
                // only set id if its changed, such as we did property
                // placeholder
                if (!originalId.equals(id)) {
                    route.setId(id);
                }
                customIds.add(id);
            } else {
                RestDefinition rest = route.getRestDefinition();
                if (rest != null && route.isRest()) {
                    VerbDefinition verb = findVerbDefinition(rest, 
route.getInput().getEndpointUri());
                    if (verb != null) {
                        String id = verb.getId();                               
                                                                                
                                                                    <- line 154
                        if (verb.hasCustomIdAssigned() && 
ObjectHelper.isNotEmpty(id) && !customIds.contains(id)) {
                            route.setId(id);
                            customIds.add(id);
                        }
                    }
                }
            }
        }


From: Nikola Glidzic
Sent: Monday, December 12, 2022 1:13 PM
To: users@camel.apache.org<mailto:users@camel.apache.org>
Subject: BUG - missing configuration placeholder possibility for id in REST DSL

Hello Camel crew,

I think there is a bug when using placeholder for route id in REST DSL route. I 
am using Camel 3.18.4, but same problem exists in previous versions as well.

I want my REST route to have my custom route id loaded from configuration by 
using configuration placeholder, like this:

rest()
                .post("{{endpoint.uri}}")                            <- loaded 
nice
                .id("{{endpoint.id}}")                                   <- NOT 
loaded
                .type(Claim.class)
                .consumes("application/json")
                .bindingMode(RestBindingMode.json)
                .to("direct:some_channel")

Endpoint uri placeholder will be loaded good, but placeholder for id will not 
be loaded and my route id will remain as "{{endpoint.id}}".

I think mistake and fix solution for this stands in class 
RouteDefinitionHelper, in method forceAssignIds():

If you check the provided image, I think that line 154 for resolving REST route 
id should have the same placeholder resolving logic as it is in line 142.

Should I create JIRA ticket for this or will you do it? It is probably better 
if you do it, but please provide us link of JIRA ticket in response so we can 
track the progress.

Thanks in advance!
Kind Regards,
Nikola Glidzic



Reply via email to