🎄 Happy Holidays! 🥳

Most of Solace is closed December 24–January 1 so our employees can spend time with their families. We will re-open Thursday, January 2, 2024. Please expect slower response times during this period and open a support ticket for anything needing immediate assistance.

Happy Holidays!

Please note: most of Solace is closed December 25–January 2, and will re-open Tuesday, January 3, 2023.

Acknowledging messages using Spring JMS

asx19
asx19 Member Posts: 2

Hello,
I would like to manually acknowledge each message I receive from the Solace queue using the JMS protocol. However with the configuration I have below, I am seeing that the messages are actually not being removed even after I explicitly call "message.acknowledge()" on the message.

@Bean()
    public DefaultJmsListenerContainerFactory connectionFactory(SolConnectionFactory solConnectionFactory, SolaceErrorHandler errorHandler) {
        DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
        factory.setConnectionFactory(solConnectionFactory);
        factory.setErrorHandler(errorHandler);
        factory.setSessionAcknowledgeMode(Session.CLIENT_ACKNOWLEDGE);
        return factory;
    }

I couldn't really find much documentation on manually ack-ing each message in the application. Should I be changing something here?

Thanks in advance

Tagged:

Best Answer

  • asx19
    asx19 Member Posts: 2
    edited August 2020 #2 Answer ✓

    Hi @marc,
    Thanks-- using SupportedProperty.SOL_CLIENT_ACKNOWLEDGE indeed solved the problem.

Answers

  • marc
    marc Member, Administrator, Moderator, Employee Posts: 963 admin
    edited August 2020 #3

    Hi @asx19 ,
    Are you using the @JmsListener annotation on the receiving method?
    If yes, can you try adding a name of "jmsListenerContainerFactory" to your DefaultJmsListenerContainerFactory bean and seeing if that works for you?

        @Bean(name = "jmsListenerContainerFactory")
        public DefaultJmsListenerContainerFactory connectionFactory(SolConnectionFactory solConnectionFactory) {
            DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
            factory.setConnectionFactory(solConnectionFactory);
            factory.setErrorHandler(errorHandler);
            factory.setSessionAcknowledgeMode(Session.CLIENT_ACKNOWLEDGE);
            return factory;
        }
    

    Once you get it working another thing to look into is whether you want to use the JMS default Session.CLIENT_ACKNOWLEDGE or if you want to use SupportedProperty.SOL_CLIENT_ACKNOWLEDGE

    Hope that helps!
    -Marc

  • asx19
    asx19 Member Posts: 2
    edited August 2020 #4 Answer ✓

    Hi @marc,
    Thanks-- using SupportedProperty.SOL_CLIENT_ACKNOWLEDGE indeed solved the problem.

  • marc
    marc Member, Administrator, Moderator, Employee Posts: 963 admin

    @asx19 said:
    Hi @marc,
    Thanks-- using SupportedProperty.SOL_CLIENT_ACKNOWLEDGE indeed solved the problem.

    Awesome, glad I could help!