Hi I created a ticket https://issues.apache.org/jira/browse/CAMEL-17567
On Sat, Jan 29, 2022 at 7:09 PM Claus Ibsen <claus.ib...@gmail.com> wrote: > > On Fri, Jan 28, 2022 at 10:36 PM Chirag <chirag.sangh...@gmail.com> wrote: > > > > Yes and it worked successfully. I could not get the original method to > > work (including application.properties or other properties set at > > context). This is primarily POC so I am happy that the "fast" method > > worked. > > > > I feel that > > https://camel.apache.org/manual/camel-3x-upgrade-guide-3_4.html#_using_custom_type_converters > > should be updated to indicate that if project is using maven then > > might as well move to @Converter (generateLoader = true). > > > > Thanks for the doc update. > > Yeah, using generate loader = true is recommended. > > However I think it's worth to get the annotation scanner to work with > camel-main too, as it can benefit when you use camel-jbang > as well, where you can quickly try out and prototype with camel. > > > > > > > > ચિરાગ/चिराग/Chirag > > ------------------------------------------ > > Sent from My Gmail Account > > > > On Fri, Jan 28, 2022 at 4:18 AM Claus Ibsen <claus.ib...@gmail.com> wrote: > > > > > > On Thu, Jan 27, 2022 at 8:36 PM Chirag <chirag.sangh...@gmail.com> wrote: > > > > > > > > I stumbled upon :) > > > > > > > > https://camel.apache.org/components/3.14.x/others/main.html > > > > > > > > It says - Its recommended to migrate to use fast type converter > > > > loading by setting Converter(loader = true) on your custom type > > > > converter classes. > > > > > > > > I couldn't make the original method work - but it does work with > > > > @Converter(generateLoader = true), and running mvn package. > > > > > > > > > > Ah good, then you are using the maven plugin to generate the loader > > > source code, > > > which Camel then detects when starting up and can find your custom > > > type converter. > > > > > > Then this converter is loaded in the same way as the out of the box > > > converters. > > > > > > > > > > > > > > > > > > > ચિરાગ/चिराग/Chirag > > > > ------------------------------------------ > > > > Sent from My Gmail Account > > > > > > > > On Thu, Jan 27, 2022 at 12:58 PM Chirag <chirag.sangh...@gmail.com> > > > > wrote: > > > > > > > > > > It doesn't seem to be helping. > > > > > Let me do some digging. > > > > > > > > > > ચિરાગ/चिराग/Chirag > > > > > ------------------------------------------ > > > > > Sent from My Gmail Account > > > > > > > > > > On Thu, Jan 27, 2022 at 3:16 AM Claus Ibsen <claus.ib...@gmail.com> > > > > > wrote: > > > > > > > > > > > > Hi > > > > > > > > > > > > Ah yeah there is no classpath annotation scanning like you can have > > > > > > with spring boot / quarkus. > > > > > > > > > > > > However for loading custom type converters where you have that file > > > > > > in > > > > > > the classpath, then you can try setting > > > > > > camel.main.loadTypeConverters=true > > > > > > > > > > > > > > > > > > On Thu, Jan 27, 2022 at 5:37 AM Chirag <chirag.sangh...@gmail.com> > > > > > > wrote: > > > > > > > > > > > > > > I am trying out following > > > > > > > https://camel.apache.org/blog/2020/05/CdcWithCamelAndDebezium/ > > > > > > > > > > > > > > with few changes: > > > > > > > 1. Using MySQL > > > > > > > 2. Trying to use a TypeConverter > > > > > > > > > > > > > > I have created a class called Customer - Here is snippet: > > > > > > > > > > > > > > public class Customer { > > > > > > > public long getId() { > > > > > > > return id; > > > > > > > } > > > > > > > > > > > > > > public void setId(long id) { > > > > > > > this.id = id; > > > > > > > } > > > > > > > > > > > > > > public String getFirst_name() { > > > > > > > return first_name; > > > > > > > } > > > > > > > > > > > > > > With that - Created a TypeConverter class with a method as below. > > > > > > > > > > > > > > @Converter > > > > > > > public static Customer toCustomer(final Struct struct) { > > > > > > > logger.debug("toCustomer"); > > > > > > > return new Customer(struct.getInt64("ID"), > > > > > > > struct.getString("FIRST_NAME"),struct.getString("LAST_NAME"), > > > > > > > struct.getString("EMAIL")); > > > > > > > } > > > > > > > > > > > > > > The class is listed in > > > > > > > Project\src\main\resources\META-INF\services\org\apache\camel\TypeConverter > > > > > > > file > > > > > > > > > > > > > > Following fails: > > > > > > > > > > > > > > from("debezium-mysql:mydb....).convertBodyTo(Customer.class) > > > > > > > .marshal().json(JsonLibrary.Gson) > > > > > > > .to("file:/Folder/SomeData"); > > > > > > > > > > > > > > Following Works: > > > > > > > from("debezium-mysql:mydb....).convertBodyTo(Map.class) > > > > > > > .marshal().json(JsonLibrary.Gson) > > > > > > > .to("file:/Folder/SomeData"); > > > > > > > > > > > > > > With Map.class my understanding is that it invokes - > > > > > > > debeziumtypeconverter and works fine. > > > > > > > > > > > > > > Similarly - I want to invoke My Customerl.class. > > > > > > > > > > > > > > org.apache.camel.InvalidPayloadException: No body available of > > > > > > > type: > > > > > > > com.company.Customer but has value: > > > > > > > Struct{ID=1,FIRST_NAME=MyName,LAST_NAME=MyLastName,EMAIL=myem...@myorg.com} > > > > > > > of type: org.apache.kafka.connect.data.Struct on: Message. > > > > > > > Caused by: No type converter available to convert from type: > > > > > > > org.apache.kafka.connect.data.Struct to the required type: > > > > > > > com.company.Customer with value > > > > > > > Struct{ID=1,FIRST_NAME=MyName,LAST_NAME=MyLastName,EMAIL=myem...@myorg.com}. > > > > > > > Exchange[0EDB7CF530EA352-0000000000000001]. > > > > > > > Caused by: [org.apache.camel.NoTypeConversionAvailableException - > > > > > > > No > > > > > > > type converter available to convert from type: > > > > > > > org.apache.kafka.connect.data.Struct to the required type: > > > > > > > com.company.Customer with value > > > > > > > Struct{ID=1,FIRST_NAME=MyName,LAST_NAME=MyLastName,EMAIL=myem...@myorg.com}] > > > > > > > at > > > > > > > org.apache.camel.support.MessageSupport.getMandatoryBody(MessageSupport.java:125) > > > > > > > at > > > > > > > org.apache.camel.support.processor.ConvertBodyProcessor.process(ConvertBodyProcessor.java:118) > > > > > > > at org.apache.camel.support.processor.ConvertBodyProcessor.proce > > > > > > > > > > > > > > Question: > > > > > > > 1. Does Camel-Main support Annotation and the ability to register > > > > > > > TypeConverter automatically? > > > > > > > 2. I see a slightly different way of defining TypeConverter > > > > > > > https://github.com/debezium/debezium-examples/blob/main/camel-component/qa-camel/src/main/java/io/debezium/examples/camel/pipeline/Converters.java > > > > > > > - but this doesn't even seem to use META-INF or a registry - so > > > > > > > not > > > > > > > sure how it would work. > > > > > > > > > > > > > > ચિરાગ/चिराग/Chirag > > > > > > > ------------------------------------------ > > > > > > > Sent from My Gmail Account > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > > Claus Ibsen > > > > > > ----------------- > > > > > > http://davsclaus.com @davsclaus > > > > > > Camel in Action 2: https://www.manning.com/ibsen2 > > > > > > > > > > > > -- > > > Claus Ibsen > > > ----------------- > > > http://davsclaus.com @davsclaus > > > Camel in Action 2: https://www.manning.com/ibsen2 > > > > -- > Claus Ibsen > ----------------- > http://davsclaus.com @davsclaus > Camel in Action 2: https://www.manning.com/ibsen2 -- Claus Ibsen ----------------- http://davsclaus.com @davsclaus Camel in Action 2: https://www.manning.com/ibsen2