Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log with KafkaProducer does not work #1862

Closed
tstuber opened this issue Oct 1, 2020 · 5 comments
Closed

Log with KafkaProducer does not work #1862

tstuber opened this issue Oct 1, 2020 · 5 comments

Comments

@tstuber
Copy link
Contributor

tstuber commented Oct 1, 2020

Hi

I am facing an issue with Quarkus Camel and Kafka. I use the following route:

    @Override
    public void configure() throws Exception {

        getContext().setStreamCaching(true);
        getContext().setTracing(true);

        from("platform-http:/entries?httpMethodRestrict=POST")
                .to("kafka:{{kafka.topic}}"
                   + "?brokers={{kafka.bootstrap.servers}}")
                .log("whatever")
            ;
    }

I want to write a log entry after the message has been sent to Kafka. Having this .log() component set, I get the following error when calling the endpoint:

$ curl -H "Content-Type: application/json" -X POST --data '{"id":"1","message":"whatever"}' localhost:8080/entries
java.lang.NullPointerException
        at org.apache.camel.processor.CamelInternalProcessor$TracingAdvice.before(CamelInternalProcessor.java:874)
        at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:237)
        at org.apache.camel.processor.Pipeline$PipelineTask.run(Pipeline.java:90)
        at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:148)
        at org.apache.camel.impl.engine.DefaultReactiveExecutor.schedule(DefaultReactiveExecutor.java:55)
        at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask.lambda$run$0(RedeliveryErrorHandler.java:398)
        at org.apache.camel.processor.SendProcessor.lambda$process$0(SendProcessor.java:162)
        at org.apache.camel.component.kafka.KafkaProducer$KafkaProducerCallBack$1.run(KafkaProducer.java:492)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)

From the apps logs, the route seems to stop just after calling kafka. The log component is not listed in the trace. There is also no exception or something like that. Same when checking debug logs. The route just seems to end.

2020-10-01 12:26:40,774 INFO  [org.apa.cam.Tracing] (vert.x-eventloop-thread-7) *--> [post-transfo] [from[platform-http:/entries?httpM] Exchange[Id: 8C0A747DF97BA1C-0000000000000001, BodyType: byte[], Body: {"id":"1","message":"whatever"}]
2020-10-01 12:26:40,774 INFO  [org.apa.cam.Tracing] (vert.x-eventloop-thread-7)      [post-transfo] [kafka:{{kafka.topic}}?brokers={{k] Exchange[Id: 8C0A747DF97BA1C-0000000000000001, BodyType: byte[], Body: {"id":"1","message":"whatever"}]

When I remove the .log() component, the requests written and returned properly:

curl -H "Content-Type: application/json" -X POST --data '{"id":"1","message":"whatever"}' localhost:8080/entries
{"id":"1","message":"whatever"}

The message is written to the topic in both cases, so that is not the problem.
But I do not understand, why using a log component results in that error... Any ideas?

Thanks for your help

@tstuber tstuber changed the title KafkaProducer Log with KafkaProducer does not work Oct 1, 2020
@ppalaga
Copy link
Contributor

ppalaga commented Oct 5, 2020

Which version of Camel Quarkus and Quarkus are you using? Could you please share your pom.xml?

@tstuber
Copy link
Contributor Author

tstuber commented Oct 5, 2020

Camel Quarkus: 1.0.0
Quarkus: 1.7.0.Final

pom.xml:

<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.company.example</groupId>
    <artifactId>myproject</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <compiler-plugin.version>3.8.1</compiler-plugin.version>
        <maven.compiler.parameters>true</maven.compiler.parameters>
        <version.sonar-maven-plugin>3.7.0.1746</version.sonar-maven-plugin>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <quarkus-plugin.version>1.7.0.Final</quarkus-plugin.version>
        <quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id>
        <quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
        <quarkus.platform.version>1.7.0.Final</quarkus.platform.version>
        <surefire-plugin.version>3.0.0-M5</surefire-plugin.version>
    </properties>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>${quarkus.platform.group-id}</groupId>
                <artifactId>${quarkus.platform.artifact-id}</artifactId>
                <version>${quarkus.platform.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-resteasy</artifactId>
        </dependency>

        <!-- Camel dependencies -->
        <dependency>
            <groupId>org.apache.camel.quarkus</groupId>
            <artifactId>camel-quarkus-main</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel.quarkus</groupId>
            <artifactId>camel-quarkus-timer</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel.quarkus</groupId>
            <artifactId>camel-quarkus-jackson</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel.quarkus</groupId>
            <artifactId>camel-quarkus-file</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel.quarkus</groupId>
            <artifactId>camel-quarkus-direct</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel.quarkus</groupId>
            <artifactId>camel-quarkus-platform-http</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel.quarkus</groupId>
            <artifactId>camel-quarkus-kafka</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel.quarkus</groupId>
            <artifactId>camel-quarkus-seda</artifactId>
        </dependency>

        <!-- Monitoring / Tracing -->
        <dependency>
            <groupId>org.apache.camel.quarkus</groupId>
            <artifactId>camel-quarkus-microprofile-health</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel.quarkus</groupId>
            <artifactId>camel-quarkus-microprofile-metrics</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel.quarkus</groupId>
            <artifactId>camel-quarkus-opentracing</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel.quarkus</groupId>
            <artifactId>camel-quarkus-log</artifactId>
        </dependency>

        <!-- test dependencies -->
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-junit5</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>rest-assured</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.logging</groupId>
            <artifactId>commons-logging-jboss-logging</artifactId>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>io.quarkus</groupId>
                <artifactId>quarkus-maven-plugin</artifactId>
                <version>${quarkus-plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare</goal>
                            <goal>prepare-tests</goal>
                            <goal>build</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${compiler-plugin.version}</version>
            </plugin>
            <plugin>
                <groupId>org.sonarsource.scanner.maven</groupId>
                <artifactId>sonar-maven-plugin</artifactId>
                <version>${version.sonar-maven-plugin}</version>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${surefire-plugin.version}</version>
                <configuration>
                    <systemPropertyVariables>
                        <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
                        <maven.home>${maven.home}</maven.home>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.5</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <!-- attached to Maven test phase -->
                    <execution>
                        <id>report</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                        <configuration>
                            <xml.enabled>true</xml.enabled>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>native</id>
            <activation>
                <property>
                    <name>native</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <version>${surefire-plugin.version}</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>integration-test</goal>
                                    <goal>verify</goal>
                                </goals>
                                <configuration>
                                    <systemPropertyVariables>
                                        <native.image.path>
                                            ${project.build.directory}/${project.build.finalName}-runner
                                        </native.image.path>
                                        <java.util.logging.manager>org.jboss.logmanager.LogManager
                                        </java.util.logging.manager>
                                        <maven.home>${maven.home}</maven.home>
                                    </systemPropertyVariables>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
            <properties>
                <quarkus.package.type>native</quarkus.package.type>
            </properties>
        </profile>
    </profiles>
</project>

@tstuber
Copy link
Contributor Author

tstuber commented Oct 5, 2020

I also face the same issue when using:
Camel Quarkus: 1.1.0
Quarkus: 1.7.5.Final

@jamesnetherton
Copy link
Contributor

I can replicate this issue with Camel Quarkus 1.1.0 but not with the latest 1.2.0-SNAPSHOT.

@tstuber
Copy link
Contributor Author

tstuber commented Oct 21, 2020

Indeed, poblem is solved with camel-quarkus 1.2.0.

@tstuber tstuber closed this as completed Oct 21, 2020
@ppalaga ppalaga added this to the No fix/wont't fix milestone Dec 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants