Spring JMSListener - How should it handle empty service data?

I asked basically the same thing a few months ago with this message: How should a Spring JMS listener handle a message with an empty payload? but all I had a miserable comment suggesting that I "rewrite my listener to do what I want." Valid statement, but unclear in my eyes, as I'm still going to handle Spring-Boot. I have learned since then and want to ask this question directly again (as opposed to posting generosity on the old one).

I installed the annotated bean class with @Configurationand @EnableJms, and my factory container looks like this:

@Bean
    public DefaultJmsListenerContainerFactory jmsListenerContainerFactory() {
        DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
        factory.setConnectionFactory(mqConnectionFactory());
        factory.setDestinationResolver(destinationResolver());
        factory.setConcurrency("1");
        factory.setErrorHandler(errorHandler());
        factory.setSessionTransacted(true);
        factory.setSessionAcknowledgeMode(Session.CLIENT_ACKNOWLEDGE);
        return factory;
    }

And the listener looks like this:

@JmsListener(id = "qID", destination = "qName")
    public void processOrder(String message) {. . .}

, bean, JMSListener ( autoStartup false), , , JMSListener . " ". , "\n" , . org.springframework.messaging.converter.MessageConversionException: No converter found to convert to class java.lang.String. . -

SimpleMessageConverter, , , , - setIgnoreStringPattern(). , , , , . ? JMSListener ?

+4
2

. ( ) javax.jms.Message, . ,

@JmsListener
public void processOrder(Message message) throws JMSException {
     String convertedMessage = ((TextMessage) message).getText();
     :
     :
}

JMSException, , , ErrorHandler , , - . , .

Edit: Jonh K byte[] . . .

+1

- factory , , .

0

Source: https://habr.com/ru/post/1650205/


All Articles