Vert.x RabbitMQ 编码 NullPointerException

Vert.x RabbitMQ encode NullPointerException

我正在 Java8 工作 Vert.x 3.9.2vertx-rabbitmq-client 相同的版本。我正在尝试向交换器发布消息,但无论交换器的配置如何 (topic/fanout),都会抛出相同的异常:

 java.lang.NullPointerException
        at io.vertx.rabbitmq.impl.Utils.encode(Utils.java:179)
        at io.vertx.rabbitmq.impl.RabbitMQClientImpl.lambda$basicPublish(RabbitMQClientImpl.java:213)
        at io.vertx.rabbitmq.impl.RabbitMQClientImpl.lambda$forChannel(RabbitMQClientImpl.java:488)
        at io.vertx.core.impl.ContextImpl.lambda$executeBlocking(ContextImpl.java:313)
        at io.vertx.core.impl.TaskQueue.run(TaskQueue.java:76)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:834)

这是我的代码:

          amqpClient
             .exchangeDeclare(
                "orders", // name
                "topic", // type
                true, //durable
                false, //autodelete 
                exchangeDeclareResult -> {
                    if (exchangeDeclareResult.succeeded()) {
                        amqpClient
                            .basicPublish(
                                "orders", 
                                "test",
                                new JsonObject()..... // Another properties
                                publishResult -> {
                                    if (publishResult.succeeded())
                                        mainPromise.complete();
                                    else {
                                        publishResult.cause().printStackTrace();
                                        mainPromise.fail(publishResult.cause());
                                    }
                                });
                    } 
                    else
                        mainPromise.fail(exchangeDeclareResult.cause());
                }
            );

我认为问题出在 json 内容序列化上。我体内的每个 属性 都有内容,我的意思是没有空值。我注意到的另一个问题是调试期间异常中的一条消息:

NullPointerException@91 "java.lang.NullPointerException"
cause: NullPointerException@91 "java.lang.NullPointerException"
depth:9
backtrace Object[5]@99
stackTraceElement[9]@133
suppressedExceptions: Collections$EmptyList@101 size=0

提前致谢。

new JsonObject()... // Another properties 对象是否有具有字符串值的 body 属性?这就是 basicPulish 从消息中提取的内容。请注意,没有 属性 可能 return 为空。因此,如果您的所有属性都具有 non-null 值是不够的,您还应该具有所有必需的属性:)