spring-webfluxibm-mqspring-jmsreactorspring-dsl

@JmsListener throwing MessageConversionException


I'm trying to receive a message asynchronously from IBM MQ:

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

Catch:

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.

If I switch method type to simple void it works as supposed to. How can I set listener to receive messages in non-blocking reactive way?


Solution

  • The conversion that is failing is the input to requestProcess.

    @JmsListener has a found a publisher of type reactor.core.publisher.MonoLift, but requestProcess is expecting a Message, and it doesn't have a conversion.

    The way round this would be to changed the input signature for requestProcess to

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

    and modify the method body accordingly.