Open calohmn opened 2 years ago
As far as I see, before sending a record via KafkaProducer hono checks that lifecycle status is 'started' - hence the component hasn't received stopped event yet and the Hono hasn't called KafkaProducer.close. However, it seems to me that, the thread model of vertx KafkaProducer implies that if hono component call send-then-close the send won't fail (at least not with that stack trace). I see that Vertx kafka producer uses to register close hooks for vertx/context close/remove. So, maybe these hooks close producers on shutdown even before Hono components have got stop event.
just fyi running:
final Vertx vertx = Vertx.vertx(); ((VertxInternal)vertx).addCloseHook(p -> { System.out.println("[vertx hook before] vert closed"); p.complete();; }); vertx.deployVerticle(new AbstractVerticle() { @Override public void stop(final Promise
stopPromise) throws Exception { System.out.println("[stop] stop verticle"); super.stop(stopPromise); } }).onComplete(v -> { ((VertxInternal)vertx).addCloseHook(p -> { System.out.println("[vertx hook after] vert closed"); p.complete();; }); vertx.close(); });
produces for me:
[vertx hook before] vert closed [vertx hook after] vert closed [stop] stop verticle
so it seems that Vertx close handlers are called before stopping verticles. For context close hooks it seems that verticle stop is called before them.
When using Kafka-based messaging: On protocol adapter shutdown, there may be errors like these getting logged: