无法将ClientId设置为ArtemisConnectionFactoryConfiguration

时间:2019-07-03 21:25:16

标签: spring-jms

无法在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

之类的属性来设置连接工厂上的clientId的能力。

0 个答案:

没有答案