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

No messages emitted on start of smallrye-reactive-messaging-kafka codestart in dev mode #23018

Closed
rsvoboda opened this issue Jan 19, 2022 · 7 comments · Fixed by #23029
Closed

Comments

@rsvoboda
Copy link
Member

Describe the bug

No messages emitted on start with smallrye-reactive-messaging-kafka codestart in dev mode.

I had to adjust JAX-RS endpoint to inject MyReactiveMessagingApplication and invoke the method with emitter as part of endpoint call. When I accessed the endpoint I finally saw the log messages with the upper-case text.

Application code: https://github.com/quarkusio/quarkus/blob/main/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/reactive-messaging-codestart/java/src/main/java/org/acme/MyReactiveMessagingApplication.java#L19

In the log I noticed new lines just before the upper-case prints:

2022-01-19 16:55:03,870 INFO  [io.sma.rea.mes.kafka] (vert.x-eventloop-thread-0) SRMSG18256: Initialize record store for topic-partition 'word-0' at position -1.
2022-01-19 16:55:03,886 INFO  [io.sma.rea.mes.kafka] (vert.x-eventloop-thread-1) SRMSG18256: Initialize record store for topic-partition 'uppercase-word-0' at position -1.

Seems that kafka dev service is not fully or properly initialized to handle messages sent from onStart method

This behaviour is quite confusing and it took me some time to figure out that the code flow in MyReactiveMessagingApplication is correct and the problem is with message sending.

CC @cescoffier

Expected behavior

>> HELLO
>> WITH
>> SMALLRYE
>> REACTIVE
>> MESSAGE

gets printed on boot in dev mode

Actual behavior

Upper-case text is not printed

How to Reproduce?

  • Select quarkus-resteasy-reactive and quarkus-smallrye-reactive-messaging-kafka on https://code.quarkus.io/
  • Download the app and run mvn quarkus:dev

Output of uname -a or ver

macOS Monterey

Output of java -version

Java 17

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.6.2.Final and Quarkus main

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

@quarkus-bot
Copy link

quarkus-bot bot commented Jan 19, 2022

@cescoffier
Copy link
Member

Ok... that's annoying...
The configuration generated with the codestart is incorrect. It cannot work, or really by accident when all planets are aligned. The problem is that Kafka default uses "latest" when subscribing to a topic, which means that only new messages are going to be consumed. The record previously sent are simply ignored.

Here is the working configuration:

mp.messaging.outgoing.source-out.topic=word


mp.messaging.incoming.source-in.topic=word
mp.messaging.incoming.source-in.auto.offset.reset=earliest

mp.messaging.incoming.uppercase-in.topic=uppercase-word

mp.messaging.outgoing.uppercase-out.topic=uppercase-word

I would also recommend using the topic as channel name to reduce the configuration to:

mp.messaging.incoming.source-in.auto.offset.reset=earliest

That would be so much better...

However, I don't know where this codestart is maintained. @maxandersen / @gastaldi any link?

@cescoffier
Copy link
Member

We may want to rewrite the tests too, to use the dev service and not the in-memory connector.

@cescoffier
Copy link
Member

I think I found where is it maintained... but I got some weird YAML-based config - do we generate the properties from that Yaml?

@gastaldi
Copy link
Contributor

I think I found where is it maintained... but I got some weird YAML-based config - do we generate the properties from that Yaml?

Yes, I believe so

@cescoffier
Copy link
Member

Ah, I got why it's done that way (with the topic set). While I believe I agreed with this, I think it is not OK. It shows what I would call an anti-pattern for simple applications (read/write to the same topic from the same application instead of using an in-memory stream). It can be useful when you want to implement checkpoints, but that's quite advanced and should not be covered by the code start.

cescoffier added a commit to cescoffier/quarkus that referenced this issue Jan 19, 2022
They could not work as they were implemented.
This PR simplifies the app and config and remote the MQTT code start.

Fix quarkusio#23018
@quarkus-bot quarkus-bot bot added this to the 2.8 - main milestone Jan 20, 2022
@gsmet gsmet modified the milestones: 2.8 - main, 2.7.0.Final Jan 21, 2022
gsmet pushed a commit to gsmet/quarkus that referenced this issue Jan 21, 2022
They could not work as they were implemented.
This PR simplifies the app and config and remote the MQTT code start.

Fix quarkusio#23018

(cherry picked from commit d84d9e8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants