1

I am trying to create a list of listeners on a list of a queue using JMS and Spring Boot. In my test I am running a Solace Docker container with test container and I publish a message in one of the queues trying to invoke one of the dynamic listeners. Sometimes the listner catch the message but most of the times I get this exception:

10:51:38.633 WARN  Setup of JMS message listener invoker failed for destination 'toto' - trying to recover. Cause: SMF AD bind response error [condition = amqp:internal-error]

This is my configuration:

import lombok.extern.slf4j.Slf4j;
import org.apache.qpid.jms.JmsConnectionFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jms.annotation.JmsListenerConfigurer;
import org.springframework.jms.config.*;
import org.springframework.jms.support.converter.MappingJackson2MessageConverter;
import org.springframework.jms.support.converter.MessageType;
import org.springframework.util.ErrorHandler;

import javax.jms.JMSException;
import java.util.UUID;

@Slf4j
@Configuration
public class ListenersConfiguration implements JmsListenerConfigurer {

    @Autowired
    private final JmsConnectionFactory connectionFactory;

    @Bean
    JmsListenerContainerFactory<?> jmsFactory(){
        DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
        factory.setConnectionFactory(connectionFactory);
        factory.setSessionTransacted(false);
        factory.setPubSubDomain(false);
        factory.setSubscriptionDurable(true);
        factory.setClientId(UUID.randomUUID().toString());
        final var objectMapper =
        new ObjectMapper()
            .findAndRegisterModules()
            .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
            .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
        final var messageConverter = new MappingJackson2MessageConverter();
        messageConverter.setObjectMapper(objectMapper);
        messageConverter.setTargetType(MessageType.TEXT);
        factory.setMessageConverter(messageConverter);

        return factory;
    }

    @Override
    public void configureJmsListeners(JmsListenerEndpointRegistrar registrar) {
        dbbRoutes
            .getRoutes()
            .forEach(route -> {
                SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
                endpoint.setId(UUID.randomUUID().toString());
                endpoint.setDestination(route.getInput());
                try {
                    endpoint.setMessageListener(message -> {
                        try {
                            log.info("Receieved ID: {} Destination {}", message.getJMSMessageID(), message.getJMSDestination());
                        }
                        catch (JMSException e) {
                            log.info("Exception while reading message - " + e);
                        }
                    });
                    registrar.setContainerFactory(jmsFactory());
                }
                catch (Exception e) {
                    log.info("Exception - " + e);
                }
                registrar.registerEndpoint(endpoint);
            });
    }
}
Justin Bertram
  • 29,372
  • 4
  • 21
  • 43
elpazio
  • 697
  • 2
  • 9
  • 25
  • 1
    Not a very descriptive error! Could you try using Solace's dedicated Spring Boot binder, rather than a generic JMS one with AMQP? See if you have the same issue? https://github.com/SolaceProducts/solace-spring-boot – Aaron Feb 02 '23 at 11:28

0 Answers0