vedran-kolka-syntio opened a new issue, #21:
URL: https://github.com/apache/camel-kamelets-examples/issues/21

   Hi and thanks for all the examples with running Camel Routes with JBang!
   
   Still, I'm having trouble using beans to configure a route in YAML DSL, when 
a property of a Kamelet expects an object (not a string, int, ...).
   
   The bean I am using is a class I implemented as a wrapper around 
DefaultAzureCredential implementing TokenCredential, because 
DefaultAzureCredential can only be instantiated using a builder class, which I 
cannot do in YAML DSL.
   
   Use case: let's say messages on Kafka are in Avro format, and use Azure 
Schema Registry for schemas. To integrate with a service on which consumers 
only understand JSON, a Camel Route would need to read a Kafka message, 
deserialize it using the schema registry, convert to JSON, and send to the sink.
   The deserializer expects a property `schema.registry.credential` of type 
`com.azure.core.credential.TokenCredential`, which I define as a bean, but 
can't seem to reference correctly.
   
   These are the relevant parts of route definition:
   ```yaml
   # camel-k: dependency=mvn:my.custom.azure.credential:eventhubs:0.1
   
   - beans:
     - name: defaultAzureCredential
       type: "#classs:my.custom.azure.credential.SimpleCredential"
   
   - route:
       id: "kafka-to-mq"
       from:
         uri: "kafka:{{kafka.kafka-to-mq-topic}}"
         parameters:
           brokers: "{{kafka.bootstrapServers}}"
           ...
           valueDeserializer: 
'com.microsoft.azure.schemaregistry.kafka.avro.KafkaAvroDeserializer'
           additionalProperties.schema.registry.url: 
'{{kafka.schema-registry-url}}'
           additionalProperties.schema.registry.credential: 
'{{bean:defaultAzureCredential}}'
           ...
   ```
   The error when running `camel run route.yaml --properties 
application.properties`:
   ```
   Caused by: java.lang.ClassCastException: class java.lang.String cannot be 
cast to class com.azure.core.credential.TokenCredential (java.lang.String is in 
module java.base of loader 'bootstrap'; 
com.azure.core.credential.TokenCredential is in unnamed module of loader 
org.apache.camel.main.download.DependencyDownloaderClassLoader @1fdfafd2)
   ```
   Referencing the bean like this (which works for the headerDeserializer):
   ```yaml
   additionalProperties.schema.registry.credential: '#defaultAzureCredential'
   ```
   results with the same Exception.
   
   Basically, my question is: Is it possible to use custom SerDe classes for 
integration with various schema registries (in this case, Azure Schema 
Registry), as you would in a normal Kafka consumer/producer microservice, but 
in Camel's YAML DSL?


-- 
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: commits-unsubscr...@camel.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to