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/13 23:36:00 UTC

[jira] [Updated] (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:all-tabpanel ]

Franky Georg updated CAMEL-15686:
---------------------------------
    Description: 
Injecting an EndpointProducerBuilder bean that uses a simple expression causes an exception.
{code:java}
@Autowired
@Qualifier("publishToKafkaEndpoint")
EndpointProducerBuilder publishToKafkaEndpoint;

@Bean
org.apache.camel.builder.EndpointProducerBuilder publishToKafkaEndpoint() {
    return kafka("${exchangeProperty.destination}");
 }{code}
 Exception from org.apache.kafka.clients.Metadata:
{code:java}
Metadata response reported invalid topics [${exchangeProperty.destination}]{code}
 

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.

  was:
Injecting an EndpointProducerBuilder bean that uses a simple expression causes an exception.

 
{code:java}
@Autowired
@Qualifier("publishToKafkaEndpoint")
EndpointProducerBuilder publishToKafkaEndpoint;

@Bean
org.apache.camel.builder.EndpointProducerBuilder publishToKafkaEndpoint() {
    return kafka("${exchangeProperty.destination}");
 }{code}
 

Exception from org.apache.kafka.clients.Metadata:
{code:java}
Metadata response reported invalid topics [${exchangeProperty.destination}]{code}
 

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.

 


> 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.3
>  * Spring Boot 2.3.4
>            Reporter: Franky Georg
>            Priority: Minor
>
> Injecting an EndpointProducerBuilder bean that uses a simple expression causes an exception.
> {code:java}
> @Autowired
> @Qualifier("publishToKafkaEndpoint")
> EndpointProducerBuilder publishToKafkaEndpoint;
> @Bean
> org.apache.camel.builder.EndpointProducerBuilder publishToKafkaEndpoint() {
>     return kafka("${exchangeProperty.destination}");
>  }{code}
>  Exception from org.apache.kafka.clients.Metadata:
> {code:java}
> Metadata response reported invalid topics [${exchangeProperty.destination}]{code}
>  
> 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)