4

How can I configure my Spring listener to receive multiple JMS messages per session from Solace? My current JMS configuration is as follows:

@Bean
public DefaultJmsListenerContainerFactory listenerContainerFactory(ConnectionFactory connectionFactory, @Value("${jms.max-listeners}") Integer maxListeners) {

    DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
    factory.setConnectionFactory(connectionFactory);
    factory.setConcurrency("1-" + maxListeners);
    factory.setSessionAcknowledgeMode(Session.SESSION_TRANSACTED);
    factory.setSessionTransacted(true);
    factory.setCacheLevel(DefaultMessageListenerContainer.CACHE_CONSUMER);

    return factory;
}

@JmsListener(containerFactory = "listenerContainerFactory", destination = "${jms.my-queue}")
public void receive(String messages) {
    try {
        ...
    } catch (Exception e) {
        ...
    }
}

The payloads need to be single messages, however I'd like to consume many of them in each transaction so that I'm able to batch persist to my persistent store.

Typically this is done with the Solace Native API, but I'd like to abstract our JMS implementation with Spring because it alleviates the nasty boiler plate that comes alongside that API.

wild_nothing
  • 2,845
  • 1
  • 35
  • 47

0 Answers0