jamesnetherton opened a new issue, #7640:
URL: https://github.com/apache/camel-quarkus/issues/7640

   I noticed that `beanio` & `csv` tests occasionally fail on CI. It's due to 
`camel.dataformat.*` config not being applied properly.
   
   When I added some debug logging, it reveals something interesting.
   
   **Successful CSV test**
   
   `CamelQuarkusDataFormatConfigLifecycleStrategy` is registered by 
`CamelContextRecorder` before Camel routes are started.
   
   ```
   ====> registerDataFormatLifecycleStrategy build time run recorder
   [INFO] Running org.apache.camel.quarkus.component.csv.it.CsvTest
   ====> registerDataFormatLifecycleStrategy start
   ====> CamelQuarkusDataFormatConfigLifecycleStrategy constructor
   ====> registerDataFormatLifecycleStrategy end
   ====> lifecycleStrategy: 
org.apache.camel.impl.engine.OnCamelContextLifecycleStrategy
   ====> lifecycleStrategy: 
org.apache.camel.impl.engine.CustomizersLifecycleStrategy
   ====> lifecycleStrategy: 
org.apache.camel.impl.engine.DefaultAutowiredLifecycleStrategy
   ====> lifecycleStrategy: 
org.apache.camel.quarkus.core.dataformat.CamelQuarkusDataFormatConfigLifecycleStrategy
   2025-08-15 12:59:21,654 INFO  [org.apa.cam.qua.cor.CamelBootstrapRecorder] 
(main) Apache Camel Quarkus 3.26.0-SNAPSHOT is starting
   2025-08-15 12:59:21,656 INFO  [org.apa.cam.mai.MainSupport] (main) Apache 
Camel (Main) 4.13.0 is starting
   ```
   
   **Failing CSV test**
   
   In the failing case, `CamelQuarkusDataFormatConfigLifecycleStrategy` is 
registered **_after_** routes are started. So the data format configs are not 
applied.
   
   ```
   ====> registerDataFormatLifecycleStrategy build time run recorder
   [INFO] Running org.apache.camel.quarkus.component.csv.it.CsvTest
   2025-08-15 12:59:37,118 INFO  [org.apa.cam.qua.cor.CamelBootstrapRecorder] 
(main) Apache Camel Quarkus 3.26.0-SNAPSHOT is starting
   2025-08-15 12:59:37,119 INFO  [org.apa.cam.mai.MainSupport] (main) Apache 
Camel (Main) 4.13.0 is starting
   2025-08-15 12:59:37,194 INFO  [org.apa.cam.mai.BaseMainSupport] (main) 
Auto-configuration summary
   2025-08-15 12:59:37,194 INFO  [org.apa.cam.mai.BaseMainSupport] (main)     
[MicroProfilePropertiesSource] camel.dataformat.csv.ignoreSurroundingSpaces = 
true
   2025-08-15 12:59:37,288 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] 
(main) Apache Camel 4.13.0 (camel-1) is starting
   2025-08-15 12:59:37,291 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] 
(main) Routes startup (total:2)
   2025-08-15 12:59:37,291 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] 
(main)     Started route1 (direct://json-to-csv)
   2025-08-15 12:59:37,291 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] 
(main)     Started route2 (direct://csv-to-json)
   2025-08-15 12:59:37,291 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] 
(main) Apache Camel 4.13.0 (camel-1) started in 3ms (build:0ms init:0ms 
start:3ms boot:739ms)
   ====> registerDataFormatLifecycleStrategy start
   ====> CamelQuarkusDataFormatConfigLifecycleStrategy constructor
   ====> registerDataFormatLifecycleStrategy end
   ====> lifecycleStrategy: 
org.apache.camel.impl.engine.OnCamelContextLifecycleStrategy
   ====> lifecycleStrategy: 
org.apache.camel.impl.engine.CustomizersLifecycleStrategy
   ====> lifecycleStrategy: org.apache.camel.main.MainLifecycleStrategy
   ====> lifecycleStrategy: org.apache.camel.main.MainAutowiredLifecycleStrategy
   ====> lifecycleStrategy: 
org.apache.camel.impl.engine.DefaultVariableRepositoryFactory$1
   ====> lifecycleStrategy: 
org.apache.camel.quarkus.core.dataformat.CamelQuarkusDataFormatConfigLifecycleStrategy
   ```
   
   I think the general problem is that any `RUNTIME_INIT` build steps that 
consume `CamelContextBuildItem` and use recorder methods to customize the 
`CamelContext`, will not have their execution order guaranteed. So the runtime 
can be started before other configuration steps have completed.
   
   We should probably move the majority of the extension runtime `CamelContext` 
configuration steps into their own dedicated `CamelContextCustomizer`. That way 
they'll be guaranteed to execute before the runtime is started.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to