Search code examples
apache-kafkaapache-camelquarkusmicrometer

Disable Kafka and Micrometer in Apache Camel tests using Quarkus?


We are using Quarkus 2.11.3.Final along with camel-quarkus-micrometer, plus quarkus-micrometer-registry-prometheus and camel-quarkus-microprofile-health. The problem is that when we run the tests, the following exceptions are thrown:

2023-04-17 18:45:33,275 WARN  [org.apa.cam.sup.EventHelper] (main) Error notifying event 9C0D3FDCA14EBDA-0000000000000000 exchange completed. This exception will be ignored.: java.lang.NullPointerException: Cannot invoke "org.apache.camel.Endpoint.getEndpointUri()" because "endpoint" is null
        at org.apache.camel.component.micrometer.eventnotifier.MicrometerExchangeEventNotifierNamingStrategy.getTags(MicrometerExchangeEventNotifierNamingStrategy.java:53)
        at org.apache.camel.component.micrometer.eventnotifier.MicrometerExchangeEventNotifier.handleDoneEvent(MicrometerExchangeEventNotifier.java:104)
        at org.apache.camel.component.micrometer.eventnotifier.MicrometerExchangeEventNotifier.notify(MicrometerExchangeEventNotifier.java:75)
        at org.apache.camel.support.EventHelper.doNotifyEvent(EventHelper.java:1351)

(...)

Also, I see that Quarkus attempts to connect to the Kafka instance, so I ended up having to set up the Kafka devservice so at least we didn't have to see any error messages related to that.

Is there any way we can disable those? Thank you in advance.


Solution

  • To disable Kafka devservices you can add configuration to application.properties:

    quarkus.kafka.devservices.enabled=false
    

    To disable Micrometer for testing add:

    %test.quarkus.micrometer.enabled=false
    

    Or if you want more fine grained control over Camel Micrometer, there are some additional configuration options to enable / disable specific features:

    https://camel.apache.org/camel-quarkus/3.0.x/reference/extensions/micrometer.html#extensions-micrometer-additional-camel-quarkus-configuration