Apache-Camel:2.12.2,activemq:5.7
我们注意到在以下路线中,限制在前100次交换中正常工作。之后,它不是每秒发送100次交换,而是每秒只发送1次交换。现在,如果我们设置timePeriodMillis = 100,它似乎工作正常。请注意,我们同时发送500个交换。
<bean id="myProject" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="connectionFactory" ref="myProjectPooledConnectionFactory" />
<property name="preserveMessageQos" value="true" />
<property name="transacted" value="false" />
<property name="maxConcurrentConsumers" value="10" />
</bean>
<bean id="myProjectPooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory" destroy-method="stop" init-method="start">
<property name="connectionFactory" ref="myProjectAmqConnectionFactory" />
<property name="maxConnections" value="20" />
<property name="idleTimeout" value="0" />
</bean>
<bean id="myProjectAmqConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory" >
<property name="brokerURL" value="${myProject.broker.url}" />
<property name="copyMessageOnSend" value="false" />
<property name="useAsyncSend" value="true" />
</bean>
<!-- Local ActiveMQ Configuration -->
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="connectionFactory" ref="pooledConnectionFactory"/>
<property name="transacted" value="false"/>
<property name="maxConcurrentConsumers" value="500"/>
</bean>
<bean id="pooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory" destroy-method="stop" init-method="start">
<property name="connectionFactory" ref="amqConnectionFactory" />
<property name="maxConnections" value="1" />
<property name="idleTimeout" value="0" />
</bean>
<bean id="amqConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory" >
<property name="brokerURL" value="${broker.url}" />
<property name="copyMessageOnSend" value="false" />
<property name="useAsyncSend" value="true" />
</bean>
<route id="myProject.outbound.traffic" errorHandlerRef="error.handler.myProject">
<from uri="{{queue.myProject.mint.in}}{{queue.myProject.mint.in.args}}"/>
<throttle timePeriodMillis="1000" >
<constant>100</constant>
<process ref="myProjectProcessor" />
<inOnly uri="myProject:{{queue.myProject}}">
<log logName="myProject.myProjectProcessor" loggingLevel="INFO" message="this is a test message" />
</throttle>
</route>
答案 0 :(得分:0)
我的一位同事找到了答案。这是骆驼2.12.2中的一个错误,似乎已经在2.12.3中解决了。它与将交换分配给插槽的方式有关。不是检查插槽是否处于活动状态,而应检查插槽是否已经过去。
protected synchronized TimeSlot nextSlot() {
if (slot == null) {
slot = new TimeSlot();
}
if (slot.isFull() || !slot.isActive()) {
slot = slot.next();
}
slot.assign();
return slot;
}
请参阅here