@JmsListener 抛出 MessageConversionException

@JmsListener throwing MessageConversionException

我正在尝试从 IBM MQ 异步接收消息:

@JmsListener(destination = "queue", containerFactory = "Factory", id = "start")
    public Mono<Void> requestProcess(Message message) {return Mono.just("").then();  
}

捕获:

Caused by: org.springframework.jms.support.converter.MessageConversionException: Cannot convert object of type [reactor.core.publisher.MonoLift] to JMS message. Supported message payloads are: String, byte array, Map<String,?>, Serializable object.

如果我将方法类型切换为简单 void,它会按预期工作。如何设置侦听器以非阻塞反应方式接收消息?

失败的转换是 requestProcess 的输入。

@JmsListener 已找到 reactor.core.publisher.MonoLift 类型的发布商,但 requestProcess 需要 Message,但没有转化。

解决方法是将 requestProcess 的输入签名更改为

@JmsListener(destination = "queue", containerFactory = "Factory", id = "start")
    public Mono<Void> requestProcess(MonoLift<?> publisher) {
       ...

    }

并相应地修改方法体。