Camel Artemis 连接池不符合 JMS 2.0
Camel Artemis Connection Pool not JMS 2.0 Compliant
我正在尝试让 Camel 与 Artemis 和连接池一起使用。我正在使用以下技术堆栈。
- Springboot: 2.3.1.RELEASE
- 骆驼:3.4.1
连接池是使用以下依赖项创建的:
- org.messaginghub.pooled-jms.JmsPoolConnectionFactory
- org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory
我在启动过程中仍然看到消息:
o.m.pooled.jms.JmsPoolConnectionFactory : JMS ConnectionFactory on classpath is not a JMS 2.0+ version
连接工厂来自 Artemis 代码库,所以不确定为什么 JmsPoolConnectionFactory 会这么说。
查看下面我的代码:
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.apache.camel.component.jms.JmsComponent;
import org.apache.camel.component.jms.JmsConfiguration;
import org.messaginghub.pooled.jms.JmsPoolConnectionFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.jms.JMSException;
@Configuration
public class ApplicationConfiguration {
private ActiveMQConnectionFactory connectionFactory = new org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory();
@Bean
public JmsComponent jms() throws JMSException {
// Create the connectionfactory which will be used to connect to Artemis
connectionFactory.setBrokerURL("(tcp://artemo-activemq-artemis-master-0.artemo-activemq-artemis-master.default.svc.cluster.local:61616,tcp://artemo-activemq-artemis-master-1.artemo-activemq-artemis-master.default.svc.cluster.local:61616)");
connectionFactory.setUseTopologyForLoadBalancing(true);
connectionFactory.setUser("artemis");
connectionFactory.setPassword("artemis");
connectionFactory.setConsumerWindowSize(8388608);
JmsPoolConnectionFactory pooledConnectionFactory = new JmsPoolConnectionFactory();
pooledConnectionFactory.setMaxConnections(16);
pooledConnectionFactory.setConnectionFactory(connectionFactory);
JmsConfiguration jmsConfiguration = new JmsConfiguration();
jmsConfiguration.setConcurrentConsumers(16);
jmsConfiguration.setArtemisStreamingEnabled(true);
jmsConfiguration.setTransacted(true);
jmsConfiguration.setConnectionFactory(pooledConnectionFactory);
// Create the Camel JMS component and wire it to our Artemis connectionfactory
JmsComponent jms = new JmsComponent();
jms.setConfiguration(jmsConfiguration);
return jms;
}
}
我相信这里的消息指的是类路径上的 javax.jms.ConnectionFactory
接口 ,而不是 javax.jms.ConnectionFactory
的 ActiveMQ Artemis 实现。因此,您应该检查类路径中 JMS API 的版本。这是 ActiveMQ Artemis 使用的依赖项:
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jms_2.0_spec</artifactId>
<version>1.0-alpha-2</version>
</dependency>
我正在尝试让 Camel 与 Artemis 和连接池一起使用。我正在使用以下技术堆栈。
- Springboot: 2.3.1.RELEASE
- 骆驼:3.4.1
连接池是使用以下依赖项创建的:
- org.messaginghub.pooled-jms.JmsPoolConnectionFactory
- org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory
我在启动过程中仍然看到消息:
o.m.pooled.jms.JmsPoolConnectionFactory : JMS ConnectionFactory on classpath is not a JMS 2.0+ version
连接工厂来自 Artemis 代码库,所以不确定为什么 JmsPoolConnectionFactory 会这么说。
查看下面我的代码:
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.apache.camel.component.jms.JmsComponent;
import org.apache.camel.component.jms.JmsConfiguration;
import org.messaginghub.pooled.jms.JmsPoolConnectionFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.jms.JMSException;
@Configuration
public class ApplicationConfiguration {
private ActiveMQConnectionFactory connectionFactory = new org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory();
@Bean
public JmsComponent jms() throws JMSException {
// Create the connectionfactory which will be used to connect to Artemis
connectionFactory.setBrokerURL("(tcp://artemo-activemq-artemis-master-0.artemo-activemq-artemis-master.default.svc.cluster.local:61616,tcp://artemo-activemq-artemis-master-1.artemo-activemq-artemis-master.default.svc.cluster.local:61616)");
connectionFactory.setUseTopologyForLoadBalancing(true);
connectionFactory.setUser("artemis");
connectionFactory.setPassword("artemis");
connectionFactory.setConsumerWindowSize(8388608);
JmsPoolConnectionFactory pooledConnectionFactory = new JmsPoolConnectionFactory();
pooledConnectionFactory.setMaxConnections(16);
pooledConnectionFactory.setConnectionFactory(connectionFactory);
JmsConfiguration jmsConfiguration = new JmsConfiguration();
jmsConfiguration.setConcurrentConsumers(16);
jmsConfiguration.setArtemisStreamingEnabled(true);
jmsConfiguration.setTransacted(true);
jmsConfiguration.setConnectionFactory(pooledConnectionFactory);
// Create the Camel JMS component and wire it to our Artemis connectionfactory
JmsComponent jms = new JmsComponent();
jms.setConfiguration(jmsConfiguration);
return jms;
}
}
我相信这里的消息指的是类路径上的 javax.jms.ConnectionFactory
接口 ,而不是 javax.jms.ConnectionFactory
的 ActiveMQ Artemis 实现。因此,您应该检查类路径中 JMS API 的版本。这是 ActiveMQ Artemis 使用的依赖项:
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jms_2.0_spec</artifactId>
<version>1.0-alpha-2</version>
</dependency>