vertx-rabbitmq-client icon indicating copy to clipboard operation
vertx-rabbitmq-client copied to clipboard

rabbitmq client tries to reconnect while shutting down

Open rastislavpapp opened this issue 9 months ago • 5 comments

Version

4.5.7

Context

While shutting down (e.q. when a quarkus app is restarted in dev mode), the client tries to reconnect to a queue, because io.vertx.rabbitmq.impl.QueueConsumerHandler#handleShutdownSignal calls a shutdownHandler defined on a queue, which is:

handler.setShutdownHandler(sig -> {
          restartConsumer(0, handler, options);
        });

so the queue starts to reconnect on shudown, which causes an exception, and in my case, second live connection to RabbitMQ server (and eventually a third one which I don't know where came from).

The exception:

2024-06-02 09:53:07,835 ERROR [io.ver.rab.imp.RabbitMQClientImpl] (vert.x-worker-thread-4) Exception whilst running connection stablished callback:  [Error Occurred After Shutdown]: java.lang.NullPointerException: Cannot invoke "io.smallrye.context.SmallRyeContextManager.defaultThreadContext()" because the return value of "io.smallrye.context.SmallRyeContextManagerProvider.getManager()" is null
        at io.smallrye.context.SmallRyeThreadContext.getCurrentThreadContextOrDefaultContexts(SmallRyeThreadContext.java:160)
        at io.smallrye.mutiny.context.DefaultContextPropagationInterceptor.getThreadContext(DefaultContextPropagationInterceptor.java:12)
        at io.smallrye.mutiny.context.BaseContextPropagationInterceptor.decorate(BaseContextPropagationInterceptor.java:24)
        at io.smallrye.mutiny.infrastructure.Infrastructure.decorate(Infrastructure.java:149)
        at io.smallrye.mutiny.groups.UniOnItem.call(UniOnItem.java:97)
        at io.smallrye.mutiny.Uni.call(Uni.java:434)
        at io.smallrye.reactive.messaging.rabbitmq.internals.IncomingRabbitMQChannel.lambda$createConsumer$5(IncomingRabbitMQChannel.java:129)
        at io.vertx.rabbitmq.impl.RabbitMQClientImpl.connectCallbackHandler(RabbitMQClientImpl.java:867)
        at io.vertx.rabbitmq.impl.RabbitMQClientImpl.connect(RabbitMQClientImpl.java:852)
        at io.vertx.rabbitmq.impl.RabbitMQClientImpl.lambda$tryConnect$36(RabbitMQClientImpl.java:763)
        at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$1(ContextImpl.java:191)
        at io.vertx.core.impl.ContextInternal.dispatch(ContextInternal.java:279)
        at io.vertx.core.impl.ContextImpl.lambda$internalExecuteBlocking$2(ContextImpl.java:210)
        at io.vertx.core.impl.TaskQueue.run(TaskQueue.java:76)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2516)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2495)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1521)
        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:11)
        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:11)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:1583)

Do you have a reproducer?

No

Steps to reproduce

  1. start quarkus app with a rabbitmq connection in dev mode
  2. trigger restart
  3. done, you have 3 connections and an exception

Extra

  • env: quarkus 3.11.0, windows 11
  • I've also created a bug in quarkus project (https://github.com/quarkusio/quarkus/issues/39433) but after further inspection I think the problem is in this client

rastislavpapp avatar Jun 02 '24 07:06 rastislavpapp