我有2个节点,使用LeaseDatabaseLocker
和Oracle DB作为主/从运行ActiveMQ。它运行得很好,但是偶尔master会停止更新ACTIVEMQ_LOCK表15分钟。
因此,当前从属设备会迅速检测到它应该成为主设备并且确实如此。但是旧的master仍以master身份运行,并且它决定仅在随后的UPDATE ACTIVEMQ_LOCK
失败后的15分钟后才停止。
请问有人可以帮我找出问题所在吗?我们使用在CentOS上运行的apache-activemq-5.15.6。
这是我们正在使用的activemq.xml:
http://www.springframework.org/schema/beans/spring-beans.xsd http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd“>
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>file:${activemq.conf}/credentials.properties</value>
</property>
</bean>
<bean class="io.fabric8.insight.log.log4j.Log4jLogQuery" destroy-method="stop" id="logQuery" init-method="start" lazy-init="false" scope="singleton">
</bean>
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="uat-instance1" dataDirectory="${activemq.data}">
<destinationPolicy>
<policyMap>
<policyEntries>
<policyEntry topic=">">
<pendingMessageLimitStrategy>
<constantPendingMessageLimitStrategy limit="1000"/>
</pendingMessageLimitStrategy>
</policyEntry>
</policyEntries>
</policyMap>
</destinationPolicy>
<managementContext>
<managementContext createConnector="false"/>
</managementContext>
<persistenceAdapter>
<jdbcPersistenceAdapter cleanupPeriod="60000" dataDirectory="${activemq.data}/activemq-data" dataSource="#oracle-ds" lockKeepAlivePeriod="5000">
<locker>
<lease-database-locker dataSource="#oracle-ds" leaseHolderId="uat-instance1"
lockAcquireSleepInterval="10000" maxAllowableDiffFromDBTime="200000" queryTimeout="8">
</lease-database-locker>
</locker>
</jdbcPersistenceAdapter>
</persistenceAdapter>
<systemUsage>
<systemUsage>
<memoryUsage>
<memoryUsage percentOfJvmHeap="70"/>
</memoryUsage>
<storeUsage>
<storeUsage limit="100 gb"/>
</storeUsage>
<tempUsage>
<tempUsage limit="50 gb"/>
</tempUsage>
</systemUsage>
</systemUsage>
<transportConnectors>
<!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
<transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
</transportConnectors>
<shutdownHooks>
<bean xmlns="http://www.springframework.org/schema/beans" class="org.apache.activemq.hooks.SpringContextHook"/>
</shutdownHooks>
</broker>
<import resource="jetty.xml"/>
<bean class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close" id="oracle-ds">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
<property name="url" value="jdbc:oracle:thin:XXXXXXX"/>
<property name="username" value="XXXXXXX"/>
<property name="password" value="XXXXXXX"/>
<property name="maxTotal" value="200"/>
<property name="poolPreparedStatements" value="true"/>
</bean>
第二个节点在uat-instance2
中也被命名为brokerName
,在leaseHolderId
中也被命名。
从两个日志中提取如下:
2019-06-04 20:34:05,703 | DEBUG | uat-instance2, lease keepAlive Query is UPDATE ACTIVEMQ_LOCK SET BROKER_NAME=?, TIME=? WHERE BROKER_NAME=? AND ID = 1 | org.apache.activemq.store.jdbc.LeaseDatabaseLocker | ActiveMQ JDBC PA Scheduled Task
2019-06-04 20:34:05,704 | DEBUG | WriteChecker: 10000ms elapsed since last write check. | org.apache.activemq.transport.AbstractInactivityMonitor | ActiveMQ InactivityMonitor WriteCheckTimer
2019-06-04 20:34:05,705 | DEBUG | Running WriteCheck[tcp://10.77.0.62:38928] | org.apache.activemq.transport.AbstractInactivityMonitor | ActiveMQ InactivityMonitor Worker
2019-06-04 20:34:05,710 | DEBUG | Executing SQL: DELETE FROM ACTIVEMQ_MSGS WHERE (PRIORITY=? AND ID <= ( SELECT min(ACTIVEMQ_ACKS.LAST_ACKED_ID) FROM ACTIVEMQ_ACKS WHERE ACTIVEMQ_ACKS.CONTAINER=ACTIVEMQ_MSGS.CONTAINER AND ACTIVEMQ_ACKS.PRIORITY=?) ) | org.apache.activemq.store.jdbc.adapter.DefaultJDBCAdapter | ActiveMQ JDBC PA Scheduled Task
2019-06-04 20:34:05,718 | DEBUG | Deleted 0 old message(s) at priority: 5 | org.apache.activemq.store.jdbc.adapter.DefaultJDBCAdapter | ActiveMQ JDBC PA Scheduled Task
2019-06-04 20:34:05,718 | DEBUG | Cleanup done. | org.apache.activemq.store.jdbc.JDBCPersistenceAdapter | ActiveMQ JDBC PA Scheduled Task
2019-06-04 20:34:05,752 | DEBUG | WriteChecker: 10000ms elapsed since last write check. | org.apache.activemq.transport.AbstractInactivityMonitor | ActiveMQ InactivityMonitor WriteCheckTimer
2019-06-04 20:34:10,761 | DEBUG | uat-instance1, lease keepAlive Query is UPDATE ACTIVEMQ_LOCK SET BROKER_NAME=?, TIME=? WHERE BROKER_NAME=? AND ID = 1 | org.apache.activemq.store.jdbc.LeaseDatabaseLocker | main
2019-06-04 20:34:10,945 | INFO | uat-instance1, becoming master with lease expiry Tue Jun 04 20:34:20 CEST 2019 on dataSource: org.apache.commons.dbcp2.BasicDataSource@31da6b2e | org.apache.activemq.store.jdbc.LeaseDatabaseLocker | main
2019-06-04 20:34:15,958 | DEBUG | uat-instance1, lease keepAlive Query is UPDATE ACTIVEMQ_LOCK SET BROKER_NAME=?, TIME=? WHERE BROKER_NAME=? AND ID = 1 | org.apache.activemq.store.jdbc.LeaseDatabaseLocker | ActiveMQ JDBC PA Scheduled Task
2019-06-04 20:49:37,482 | DEBUG | uat-instance2 Lease held by uat-instance1 till Tue Jun 04 20:49:45 CEST 2019 | org.apache.activemq.store.jdbc.LeaseDatabaseLocker | ActiveMQ JDBC PA Scheduled Task
2019-06-04 20:49:37,483 | ERROR | uat-instance2, no longer able to keep the exclusive lock so giving up being a master | org.apache.activemq.broker.LockableServiceSupport | ActiveMQ JDBC PA Scheduled Task