...
Code Block |
---|
language | xml |
---|
title | Конфигурация ActiveMQ /etc/hydra/activemq/hydra/activemq.xml |
---|
|
...
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="${activemq.data}">
<destinationPolicy>
<policyMap>
<policyEntries>
<policyEntry topic=">" >
<!-- The constantPendingMessageLimitStrategy is used to prevent
slow topic consumers to block producers and affect other consumers
by limiting the number of messages that are retained
For more information, see:
http://activemq.apache.org/slow-consumer-handling.html
-->
<pendingMessageLimitStrategy>
<constantPendingMessageLimitStrategy limit="1000"/>
</pendingMessageLimitStrategy>
</policyEntry>
</policyEntries>
</policyMap>
</destinationPolicy>
... |
Задача
Скопилась большая очередь результатов команд, ActiveMQ медленно переносит сообщения в очередь Oracle.
Решение
При отправке сообщений в очередь Oracle, ActiveMQ завершает сессию после каждого переданного сообщения. Чтобы изменить такое поведение, настроим использование пула соединений к Oracle.
Изменим URI для очереди Oracle:
Code Block |
---|
language | xml |
---|
title | Конфигурация ActiveMQ /etc/hydra/activemq/hydra/activemq.xml |
---|
|
...
<route>
<from uri="activemq:queue:hydra_command_results_1"/>
<to uri="oraclePool:topic:AIS_NET.HP_COM_RES_1?clientId=ActiveMQ&durableSubscriptionName=HP"/>
</route>
... |
И добавим описание PooledConnectionFactory после описания oracleTopic:
Code Block |
---|
language | xml |
---|
title | Конфигурация ActiveMQ /etc/hydra/activemq/hydra/activemq.xml |
---|
|
...
<bean id="oracleTopic" class="org.apache.camel.component.jms.JmsComponent">
<property name="connectionFactory" ref="oracleTopicCredentials"/>
</bean>
<bean id="jmsPooledConnectionFactory" class="org.apache.activemq.jms.pool.PooledConnectionFactory"
init-method="start" destroy-method="stop" >
<property name="maxConnections" value="7" />
<property name="connectionFactory" ref="oracleTopicCredentials" />
</bean>
<bean id="oraclePool" class="org.apache.camel.component.jms.JmsComponent">
<property name="connectionFactory" ref="jmsPooledConnectionFactory"/>
</bean>
... |