Whats the real world use-case for additional properties as Object or Map.
What would kafka understand and use these for?

On Thu, Jan 5, 2023 at 5:12 PM Martin Pelikán <pelda...@gmail.com> wrote:

> Hi Camel experts,
>
> I am struggling with a Kafka component and passing in parameters via
> additionalProperties. I am not able to propagate an Object. I tested
> only Endpoint DSL. According to the Camel docs and APIs, I am allowed
> to pass in an instance of Map<String, Object>
>
>  Camel version: 3.18.4
>
> ----Pseudocode-----
>
> @Configuration
> Class SpringConfig
>
> @Bean(name = "autowiredMap")
> public Map<String, Object> autowiredMap() {
>     var map = new HashMap<String, Object>();
>     map.put("testStringKey3", "testStringValue3");
>     map.put("testObjectKey3", new Object());
> }
>
> -------
>
> Class MainRoute extends RouteBuilder()
>
> @Autowired
> @Qualifier("autowiredMap")
> Map<String, Object> autowiredMap;
>
> var map = new HashMap<String, Object>();
> map.put("testStringKey1", "testStringValue1");
> map.put("testObjectKey1", new Object());
>
> from(kafka(…basic configuration works)
>     .schemaRegistryURL(http://original.com)
>     .additionalProperties(map)
>     .additionalProperties("testStringKey2", "testStringValue2")
>     .additionalProperties("testObjectKey1", new Object())
>     .additionalProperties("schema.registry.url", http://overwritten.com)
>     .additionalProperties(autowiredMap)...
>
> Expected:
>
> All properties from all additionalProperties methods are propagated to
> the Kafka Properties configuration object.
>
> In reality, Properties will contain the following:
> schema.registry.url=http://overwritten.com
> testStringKey1=testStringValue1
> testStringKey2=testStringValue2
>
> Non-string values are not propagated at all. Values from autowired Map
> are not propagated at all. Autowired map is treated as
> additionalProperties.autowiredMap=HashMap@123456
>
> I can see those String values being added to the Kafka Endpoint URI:
>
> kafka://additionalProperties.testStringKey1=xxx&additionalProperties.testStringKey2=xxx&additionalProperties.schema.registr.url=xxx..
>
> Is it a bug in Camel or did I understand the documentation wrong? I
> can prepare a test case later
>
> Best regards,
>
> Martin
>


-- 
Claus Ibsen
-----------------
@davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Reply via email to