无法在Artemis自动配置期间生成的ConnectionFactory上设置ClientId
ArtemisConnectionFactoryConfiguration.java
通过定义自己的Bean(基本上与ArtemisConnectionFactoryConfiguration创建的Bean相同)来“覆盖” Artemis AutoConfiguration,从而使其能够正常工作
@Bean
public CachingConnectionFactory cachingJmsConnectionFactory(@Value("${spring.application.name}") String clientId)
throws Exception {
JmsProperties.Cache cacheProperties = this.jmsProperties.getCache();
CachingConnectionFactory connectionFactory = new CachingConnectionFactory(
createNativeConnectionFactory(ActiveMQConnectionFactory.class, this.artemisProperties));
connectionFactory.setCacheConsumers(cacheProperties.isConsumers());
connectionFactory.setCacheProducers(cacheProperties.isProducers());
connectionFactory.setSessionCacheSize(cacheProperties.getSessionCacheSize());
* connectionFactory.setClientId(clientId);*
return connectionFactory;
}
可以通过诸如spring.jms.clientId