Closed r00ta closed 3 years ago
As part of the connection process this will get a reference to the bean. This results in the post construct method being called before everything is connected.
Hi @stuartwdouglas , thank you very much for checking this. Would you suggest any workaround in the meanwhile?
I think if you moved the publisher to its own class it would work around it.
Hi @stuartwdouglas , thank you very much for the tip! With the following refactoring:
@ApplicationScoped
public class MyPublisher {
private static final Logger LOGGER = LoggerFactory.getLogger(MyPublisher.class);
private final PublishSubject<String> eventSubject = PublishSubject.create();
private int counter = 0;
@Outgoing("my-topic")
public Publisher<String> getEventPublisher() {
return eventSubject.toFlowable(BackpressureStrategy.BUFFER);
}
public void emit(final String payload) {
LOGGER.info("Emit counter: " + counter++);
eventSubject.onNext(payload);
}
}
And
@Singleton
@Startup
public class Emitter {
@Inject
MyPublisher myPublisher;
public void publish(@Observes StartupEvent event) {
myPublisher.emit("startup");
}
}
Everything works properly!
cc @cescoffier
Oh yes, that's a known issue. I need to improve the wiring.
Just a head's up - the new wiring algorithm that will be included in SmallRye Reactive Messaging 2.6.0 fixes it.
Describe the bug Using the smallrye kafka extension, if a
@PostConstruct
method of an application annotated with@Startup
creates an event, it is not emitted at all. See below an example:Expected behavior The event should be pushed to the kafka topic.
Actual behavior The event is not pushed.
To Reproduce I've created a project to reproduce the issue: https://github.com/r00ta/issues-reproducers/tree/main/quarkus-kafka-startup . The application also exposes a path
/force
that you can use to force the creation of the event: only such events are emitted properly.Steps to reproduce the behavior:
mvn clean compile quarkus:dev
localhost:9000
and have a look at themy-topic
topic on kafdrop: no events are there at all.localhost:8080/force
so to push events, you can check on kafdrop that the events are there.Configuration
Screenshots**
As you can see the event is created before the mediators are connected, I guess the problem is there.
Environment (please complete the following information):
uname -a
orver
: Linux jrota.remote.csb 4.18.0-80.11.2.el8_0.x86_64 #1 SMP Sun Sep 15 11:24:21 UTC 2019 x86_64 x86_64 x86_64 GNU/Linuxjava -version
: openjdk version "11.0.6" 2020-01-14 OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.6+10) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.6+10, mixed mode)mvnw --version
orgradlew --version
): Maven home: /home/jrota/.m2/wrapper/dists/apache-maven-3.6.3-bin/1iopthnavndlasol9gbrbg6bf2/apache-maven-3.6.3 Java version: 11.0.6, vendor: AdoptOpenJDK, runtime: /home/jrota/.jabba/jdk/adopt@1.11.0-6 Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "4.18.0-80.11.2.el8_0.x86_64", arch: "amd64", family: "unix"Additional context (Add any other context about the problem here.)