Affects: \
When I'm trying to listen through command line it works fine, but using Spring Boot it throws below error:
ERROR [org.springframework.jms.listener.DefaultMessageListenerContainer] (DefaultMessageListenerContainer-1) Could not refresh JMS Connection for destination 'wfQueue' - retrying using FixedBackOff{interval=5000, currentAttempts=44, maxAttempts=unlimited}. Cause: authentication failed javax.jms.JMSSecurityException: authentication failed This is my app class
@SpringBootApplication(scanBasePackages = {"com.source.lbm"}) public class EMSConsumerApp {
public static main(String[] args){
run(EMSConsumerApp.class, args);
}
} This class configures definitions for JMS consumer
@EnableJMS @EnableTransactionManagement public abstract class SubscriberConfiguration { private final String url; private final String clientId; private final String username; private final String password;
public SubscriberConfiguration(String url, String clientId, String username, String password) {
this.url = url;
this.clientId = clientId;
this.username = username;
this.password = password;
}
@Bean
public DefaultJmsListenerContainerFactory jsmListenerContainerFactory(ConnectionFactory connectionFactory) {
DefaultJmsListenerContainerFactory containerFactory = new DefaultJmsListenerContainerFactory();
containerFactory.setconnectionFactory(connectionFactory);
containerFactory.setPubSubDomain(true);
containerFactory.setSubscriptionDurable(true);
containerFactory.setSessionTransacted(true);
containerFactory.setAutoStartup(true);
return connectionFactory;
}
@Bean
public ConnectionFactory jmsConnectionFactory() throws JMSException{
TibjmsXATopicConnectionFactory connectionFactory = new TibjmsXATopicConnectionFactory();
connectionFactory.setServerUrl(url);
connectionFactory.setClientId(clientId);
connectionFactory.setUserName(username);
connectionFactory.setUserPassword(password);
return connectionFactory;
}
} This sets configs for a subscriber
@Configuration public class LbmSubConfiguration extends SubscriberConfiguration {
public LbmSubConfiguration(
@Value("${ems.lbm.sub.url}") String emsUrl;
@Value("${ems.lbm.sub.clientId}") String subClientId;
@Value("${ems.lbm.sub.username}") String subUsername;
@Value("${ems.lbm.sub.password}") String subPasword) {
super(emsUrl,subClientId,subUsername,subPasword);
}
} This class listenes to ems and consumes messages
@Component public class LbmEventConsumer { @JmsListener(destination = "${ems.lbm.sub.destination}", containerFactory = "jmsListenerContainerFactory") public void onMessage(BytesMessage message){ System.out.println("Message " + message); } } Since these credentials work fine on command line there shouldn't be an issue with credentials. Possibly it's because I'm missing some configs (not sure though). Can you please help me figure out what's wrong with this?
Comment From: bclozel
Thanks for getting in touch, but it feels like this is a question that would be better suited to Stack Overflow. As mentioned in the guidelines for contributing, we prefer to use the issue tracker only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug.