Search code examples
javaamqpvert.x

Java runtime warning from Vertx with AMQPBridge


I am using the following Java snippet with Vertx IO for AQMP 1.0:

    this.vertx = Vertx.vertx();

    AmqpBridge bridge = AmqpBridge.create(this.vertx);

    // Start the bridge, then use the event loop thread to process things
    // thereafter.
    bridge.start(hostname, port,
            username, password, res -> {

                // Set up a consumer using the bridge, register a handler for it.
                MessageConsumer<String> consumer = bridge
                        .createConsumer(this.processorConfiguration.getQueueName());

                // Add the message handler.
                consumer.handler(vertxMsg -> {
                    String payload = vertxMsg.body();

                    logger.debug("Rx: " + payload);
                });

                consumer.exceptionHandler(error -> {

                    logger.error("Error - " + error.getMessage());
                });
            });
}

When I run this code, I get:

2019-08-27 10:28:27,071 WARN (Slf4JLogger.java:151) - An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception. io.netty.channel.ChannelPipelineException: io.vertx.core.net.impl.VertxHandler.handlerAdded() has thrown an exception; removed. at io.netty.channel.DefaultChannelPipeline.callHandlerAdded0(DefaultChannelPipeline.java:616) at io.netty.channel.DefaultChannelPipeline.addLast(DefaultChannelPipeline.java:226) at io.netty.channel.DefaultChannelPipeline.addLast(DefaultChannelPipeline.java:192) at io.vertx.core.net.impl.NetClientImpl.connected(NetClientImpl.java:233) at io.vertx.core.net.impl.NetClientImpl.lambda$doConnect$3(NetClientImpl.java:188) at io.vertx.core.net.impl.ChannelProvider.lambda$connect$1(ChannelProvider.java:78) at io.vertx.core.net.impl.ChannelProvider.connected(ChannelProvider.java:154) at io.vertx.core.net.impl.ChannelProvider.lambda$handleConnect$2(ChannelProvider.java:137) at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:514) at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:507) at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:486) at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:427) at io.netty.util.concurrent.DefaultPromise.trySuccess(DefaultPromise.java:111) at io.netty.channel.DefaultChannelPromise.trySuccess(DefaultChannelPromise.java:82) at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.fulfillConnectPromise(AbstractNioChannel.java:300) at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:335) at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:588) at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:512) at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:426) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:398) at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:877) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.IllegalAccessError: tried to access class io.netty.channel.VoidChannelPromise from class io.vertx.core.net.impl.ConnectionBase at io.vertx.core.net.impl.ConnectionBase.(ConnectionBase.java:72) at io.vertx.core.net.impl.NetSocketImpl.(NetSocketImpl.java:84) at io.vertx.core.net.impl.NetClientImpl.lambda$connected$4(NetClientImpl.java:219) at io.vertx.core.net.impl.VertxHandler.handlerAdded(VertxHandler.java:102) at io.netty.channel.DefaultChannelPipeline.callHandlerAdded0(DefaultChannelPipeline.java:597) ... 21 more

This is only a warning, but is it something I need to resolve? I can't seem to find out what the unhandled exception is. I can't currently get my application to receive any messages, so I'm trying to work out if this is related, or (more likely) I'm doing something else stupidly wrong.

I think I got the same warning when I used the AmqpClient instead using:

https://vertx.io/docs/vertx-amqp-client/java/

Thanks


Solution

  • I had a brainwave not longer after posting and checked the POM files I was using. One of the dependencies was using an older version of Netty, which was causing this warning. I upgraded the dependency, which used a new version of Netty, the warning went away and I can now receive messages. Cheers!