essobedo commented on issue #4124:
URL: https://github.com/apache/camel-k/issues/4124#issuecomment-1485598502

   So after a deeper investigation, there are several problems. TBH I'm even 
surprised that it works in JVM mode on your side. 
   
   I had to modify several to have it work in JVM mode.
   
   1. `Integration.java`  should not have a package name
   2. `IntegrationBean` should be included in your dependency as it is not an 
integration but a Bean
   3. `CrashLoopBackOff` is due to the fact that the port has been changed for 
`8443` and this port is used to configure the probes but the port exposed by 
Quarkus is `8080` so probes always fail. I'm wondering why we can even change 
the port with the trait option `container.port`? If you want to have a 
different port, you should use `container.service-port` to set the expected 
port and leave `container.port` as it is by default. @squakez, unless I miss 
something, in which use case does it make sense to change the `containerPort` 
of the pod?
   4. The component `mapstruct` is not yet supported by Camel-Quarkus, that's 
why it doesn't work in native mode 
https://github.com/apache/camel-quarkus/issues/3994
   
   
   Here is the `Integration.java` after changing it:
   ```
    // camel-k: language=java
   // camel-k: name=issue4124-part1-integration
   
   import com.mertdotcc.sources.IntegrationBean;
   import org.apache.camel.LoggingLevel;
   import org.apache.camel.builder.RouteBuilder;
   import org.apache.camel.BindToRegistry;
   
   public class Integration extends RouteBuilder {
   
       @BindToRegistry
       public IntegrationBean IntegrationBean() {
           return new IntegrationBean();
       }
   
       @Override
       public void configure() throws Exception {
           onException(Exception.class)
                   .handled(true)
                   .setHeader("CamelHttpResponseCode").constant("400")
                   
.setBody().simple("resource:file:/etc/camel/resources/sample-error-response.json")
                   .log(LoggingLevel.ERROR, "exception", 
"${exception}").routeId("exception");
   
           // POST
           from("direct://addStudent").routeId("addStudent")
                   .log(LoggingLevel.INFO, "before-mapping", "headers: 
${headers}; body: ${body}")
                   .removeHeaders("*")
                   .convertBodyTo(String.class)
                   .process(exchange -> {
                       IntegrationBean bean =
                           (IntegrationBean) 
this.getCamelContext().getRegistry().lookupByName("IntegrationBean");
                       bean.handleMapping(exchange);
                   }) 
                   .log(LoggingLevel.INFO, "after-mapping", "headers: 
${headers}; body: ${body}");
       }
       
   }
   ```
   
   I moved `IntegrationBean` to your dependency 
https://github.com/essobedo/issue4124part2/commit/6bc07356be.
   I also use jitpack to define the location of the dependency using 
`github:essobedo/issue4124part2`
   
   here is my run.sh
   ```
   kamel run \
   --open-api file:./resources/part1-openapi.yaml \
   --resource file:./resources/sample-error-response.json \
   --dependency github:essobedo/issue4124part2 \
   --dependency mvn:org.mapstruct:mapstruct:1.5.2.Final \
   --trait container.enabled=true \
   --trait container.service-port=8443 \
   --trait container.request-cpu="250m" \
   --trait container.request-memory="256Mi" \
   --trait container.limit-cpu="500m" \
   --trait container.limit-memory="512Mi" \
   --trait health.enabled=true \
   --trait health.liveness-probe-enabled=true \
   --trait health.liveness-scheme="HTTP" \
   --trait health.liveness-initial-delay=0 \
   --trait health.liveness-timeout=10 \
   --trait health.liveness-period=15 \
   --trait health.liveness-success-threshold=1 \
   --trait health.liveness-failure-threshold=3 \
   --trait health.readiness-probe-enabled=true \
   --trait health.readiness-scheme="HTTP" \
   --trait health.readiness-initial-delay=0 \
   --trait health.readiness-timeout=10 \
   --trait health.readiness-period=15 \
   --trait health.readiness-success-threshold=1 \
   --trait health.readiness-failure-threshold=3 \
   --trait quarkus.enabled=true \
   Integration.java
   ```


-- 
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

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

Reply via email to