无法在 Camel 端点中设置 ActiveMQ 目标选项
Cannot set ActiveMQ destination option in Camel endpoint
我正在尝试在 Camel JMS (ActiveMQ) 消费者上设置预取策略。根据 Camel 文档 http://camel.apache.org/activemq.html#ActiveMQ-UsingActiveMQDestinationOptions 我应该可以通过将 ?destination.consumer.prefetchSize=1
添加到端点 URL.
来做到这一点
不幸的是,当我这样做时,我遇到了以下异常
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: activemq://queue:ToSynchronize?destination.consumer.prefetchSize=1 due to: There are 1 parameters that couldn't be set on the endpoint. Check the uri if the parameters are spelt correctly and that they are properties of the endpoint. Unknown parameters=[{destination.consumer.prefetchSize=1}]
at org.apache.camel.impl.DefaultComponent.validateParameters(DefaultComponent.java:183)
at org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:128)
at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:558)
... 48 more
我有一个简单的路线构建器
@Component
public class IntegrationRout extends RouteBuilder {
@Override
public void configure() throws Exception {
from("activemq:queue:ToSynchronize?destination.consumer.prefetchSize=1")
.unmarshal().jaxb("com.foo.jms.model")
.beanRef("Service", "upload")
}
}
以及 Java 中的 Spring 配置(取自一些关于如何配置 JMS 事务客户端的教程)
@Configuration
@EnableTransactionManagement
@ComponentScan(basePackages = {"com.foo"})
public class SynchronizationConfiguration extends CamelConfiguration {
@Bean
public ConnectionFactory jmsConnectionFactory() {
return new ActiveMQConnectionFactory("tcp://localhost:61616");
}
@Bean
@Autowired
public PlatformTransactionManager jmsTransactionManager(final ConnectionFactory jmsConnectionFactory) {
return new JmsTransactionManager(jmsConnectionFactory);
}
@Bean
@Autowired
public JmsComponent activemq(final ConnectionFactory jmsConnectionFactory, final PlatformTransactionManager jmsTransactionManager) {
return JmsComponent.jmsComponentTransacted(jmsConnectionFactory, jmsTransactionManager);
}
}
如果配置 ActiveMQ 目标选项,如 ?destination.consumer.prefetchSize=1
,您必须明确使用 ActiveMQComponent
class。用一般的JmsComponent
不行。
所以你必须更换
@Bean
@Autowired
public JmsComponent activemq(final ConnectionFactory jmsConnectionFactory, final PlatformTransactionManager jmsTransactionManager) {
return JmsComponent.jmsComponentTransacted(jmsConnectionFactory, jmsTransactionManager);
}
类似
@Bean
@Autowired
public JmsComponent activemq(final ConnectionFactory jmsConnectionFactory, final PlatformTransactionManager jmsTransactionManager) {
final ActiveMQComponent activemq = new ActiveMQComponent();
activemq.setConnectionFactory(jmsConnectionFactory);
activemq.setTransactionManager(jmsTransactionManager);
activemq.setTransacted(true);
return activemq;
}
我正在尝试在 Camel JMS (ActiveMQ) 消费者上设置预取策略。根据 Camel 文档 http://camel.apache.org/activemq.html#ActiveMQ-UsingActiveMQDestinationOptions 我应该可以通过将 ?destination.consumer.prefetchSize=1
添加到端点 URL.
不幸的是,当我这样做时,我遇到了以下异常
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: activemq://queue:ToSynchronize?destination.consumer.prefetchSize=1 due to: There are 1 parameters that couldn't be set on the endpoint. Check the uri if the parameters are spelt correctly and that they are properties of the endpoint. Unknown parameters=[{destination.consumer.prefetchSize=1}]
at org.apache.camel.impl.DefaultComponent.validateParameters(DefaultComponent.java:183)
at org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:128)
at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:558)
... 48 more
我有一个简单的路线构建器
@Component
public class IntegrationRout extends RouteBuilder {
@Override
public void configure() throws Exception {
from("activemq:queue:ToSynchronize?destination.consumer.prefetchSize=1")
.unmarshal().jaxb("com.foo.jms.model")
.beanRef("Service", "upload")
}
}
以及 Java 中的 Spring 配置(取自一些关于如何配置 JMS 事务客户端的教程)
@Configuration
@EnableTransactionManagement
@ComponentScan(basePackages = {"com.foo"})
public class SynchronizationConfiguration extends CamelConfiguration {
@Bean
public ConnectionFactory jmsConnectionFactory() {
return new ActiveMQConnectionFactory("tcp://localhost:61616");
}
@Bean
@Autowired
public PlatformTransactionManager jmsTransactionManager(final ConnectionFactory jmsConnectionFactory) {
return new JmsTransactionManager(jmsConnectionFactory);
}
@Bean
@Autowired
public JmsComponent activemq(final ConnectionFactory jmsConnectionFactory, final PlatformTransactionManager jmsTransactionManager) {
return JmsComponent.jmsComponentTransacted(jmsConnectionFactory, jmsTransactionManager);
}
}
如果配置 ActiveMQ 目标选项,如 ?destination.consumer.prefetchSize=1
,您必须明确使用 ActiveMQComponent
class。用一般的JmsComponent
不行。
所以你必须更换
@Bean
@Autowired
public JmsComponent activemq(final ConnectionFactory jmsConnectionFactory, final PlatformTransactionManager jmsTransactionManager) {
return JmsComponent.jmsComponentTransacted(jmsConnectionFactory, jmsTransactionManager);
}
类似
@Bean
@Autowired
public JmsComponent activemq(final ConnectionFactory jmsConnectionFactory, final PlatformTransactionManager jmsTransactionManager) {
final ActiveMQComponent activemq = new ActiveMQComponent();
activemq.setConnectionFactory(jmsConnectionFactory);
activemq.setTransactionManager(jmsTransactionManager);
activemq.setTransacted(true);
return activemq;
}