You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Franky Georg (Jira)" <ji...@apache.org> on 2020/10/21 22:54:00 UTC

[jira] [Comment Edited] (CAMEL-15686) Enable EndpointDSL with simple expressions within an Endpoint Builder bean

    [ https://issues.apache.org/jira/browse/CAMEL-15686?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17218035#comment-17218035 ] 

Franky Georg edited comment on CAMEL-15686 at 10/21/20, 10:53 PM:
------------------------------------------------------------------

Updated description with a full test class. Using properties:
     camel.springboot.main-run-controller=true
     camel.component.kafka.brokers=localhost:9092

-I get no errors in a clean project on 1st PC.-
 -In an existing project on 2nd PC:-

I get no errors in a clean project.

The following occurs when adding the same code to my existing project:
 # The 3 expected routes are created
 # The message is sent to Kafka via 'testTopic'
 # The message is received from Kafka via 'testTopic'
 # _Camel creates an unexpected new route_ 
`Route: route7 started and consuming from: kafka://${exchangeProperty.destination2}`
 # Camel tries to create a new topic named '${exchangeProperty.destination}' and throws an error about it being an invalid topic name

Clearly it's something to do with my existing project/environment. I'll continue trying to narrow it down, but to me it's looking more like a bug than an enhancement request at this point.


was (Author: frankyg):
Updated description with a full test class. Using properties:
    camel.springboot.main-run-controller=true
    camel.component.kafka.brokers=localhost:9092

I get no errors in a clean project on 1st PC.
In an existing project on 2nd PC:
 # The 3 expected routes are created
 # The message is sent to Kafka via 'testTopic'
 # The message is received from Kafka via 'testTopic'
 # Camel tries to create a new topic named '${exchangeProperty.destination}' and throws an error about it being an invalid topic name

Clearly it's something to do with my existing project/environment. I'll continue trying to narrow it down, but to me it's looking more like a bug than an enhancement request at this point.

> Enable EndpointDSL with simple expressions within an Endpoint Builder bean
> --------------------------------------------------------------------------
>
>                 Key: CAMEL-15686
>                 URL: https://issues.apache.org/jira/browse/CAMEL-15686
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-endpointdsl
>         Environment: Experienced with 
>  * Camel 3.4.4
>  * Spring Boot 2.3.4
>            Reporter: Franky Georg
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 3.7.0
>
>
> Injecting an EndpointProducerBuilder bean that uses a simple expression causes an exception.
> {code:java}
> @Configuration
> public class MyTestRoute extends EndpointRouteBuilder {
>    private static final String MY_TOPIC = "testTopic";
>    @Autowired
>    private EndpointProducerBuilder myKafkaBean;
>    @Override
>    public void configure() {
>       from(timer("myTimer").repeatCount(1))
>             .setBody(constant("THIS IS A TEST MESSAGE"))
>             .setProperty("destination2", constant(MY_TOPIC))
>             .to("direct:publish-to-kafka2")
>       ;
>       from("direct:publish-to-kafka2")
>             .toD(myKafkaBean)
>       ;
>       from(kafka(MY_TOPIC))
>             .log("Received: ${body}")
>       ;
>    }
>    @Bean
>    public EndpointProducerBuilder myKafkaBean() {
>       return kafka("${exchangeProperty.destination2}");
>    }
> }{code}
> Exception from org.apache.kafka.clients.Metadata:
> {code:java}
> Metadata response reported invalid topics [${exchangeProperty.destination}]{code}
> I don't have to _use_ the bean for the error to manifest, it's enough to @Autowire it.
>  
> It _does_ work for static endpoints:
> {code:java}
>     return kafka("myTopic"); // This works fine from an EndpointProducerBuilder bean{code}
> And it _does_ work for dynamic endpoints in URI form:
> {code:java}
>     return "kafka:${exchangeProperty.destination}"; // This works fine but you lose type safety{code}
>  
> Creating beans like this is useful for unit testing as they can be overridden to return mock/direct/whatever-is-useful, _without_ _first creating the original endpoint_, which can significantly reduce execution time.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)