activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Osterman...@osterman.com>
Subject Re: ACTIVEMQ_LOCK.BROKER_NAME Is Always NULL
Date Mon, 20 Dec 2010 22:44:22 GMT
After some more debugging, I think that the ACTIVEMQ_LOCK.BROKER_NAME column is simply not
maintained. I decided to dig deeper after downgrading to mysql-connector-java-5.0.8 did not
change the behavior. 

Turning on the MySQL query log and searching for all modifications of ACTIVEMQ_LOCK reveal
the following:

grep ACTIVEMQ_LOCK /tmp/mysql_query.log 

3 Query       CREATE TABLE ACTIVEMQ_LOCK( ID BIGINT NOT NULL, TIME BIGINT, BROKER_NAME VARCHAR(250),
PRIMARY KEY (ID) ) ENGINE=INNODB
3 Query       INSERT INTO ACTIVEMQ_LOCK(ID) VALUES (1)
3 Query       SELECT * FROM ACTIVEMQ_LOCK FOR UPDATE
3 Query       UPDATE ACTIVEMQ_LOCK SET TIME = 1292883941305 WHERE ID = 1
3 Query       UPDATE ACTIVEMQ_LOCK SET TIME = 1292883971306 WHERE ID = 1
3 Query       UPDATE ACTIVEMQ_LOCK SET TIME = 1292884001308 WHERE ID = 1
3 Query       UPDATE ACTIVEMQ_LOCK SET TIME = 1292884031306 WHERE ID = 1
3 Query       UPDATE ACTIVEMQ_LOCK SET TIME = 1292884061307 WHERE ID = 1

It never attempts to set the BROKER_NAME column. This is corroborated by the SQL statement
in the source code in org.apache.activemq.store.jdbc, Statements::getLockUpdateStatement()

https://svn.apache.org/repos/asf/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/Statements.java


It would seem to me that at the point it executes the UPDATE ACTIVEMQ_LOCK, it should also
be seting the BROKER_NAME column. 

   public String getLockUpdateStatement() {
        if (lockUpdateStatement == null) {
            lockUpdateStatement = "UPDATE " + getFullLockTableName() + " SET TIME = ? WHERE
ID = 1";
        }
        return lockUpdateStatement;
    }

Can any one confirm these conclusions or am I jumping the gun here? Perhaps BROKER_NAME in
the ACTIVEMQ_LOCKS table does not mean what I think it should mean. 


I apologize if this message should be posted to the ActiveMQ developers list. Please let me
know if it would be best to repost it there.



Thanks!



Erik Osterman
<e@osterman.com>
http://www.osterman.com





On Dec 17, 2010, at 5:53 PM, Erik Osterman wrote:

> I've recently setup ActiveMQ 5.4.2 in a JDBC Master-Slave sandbox configuration on localhost
(CentOS 5.4 i686) with Java(TM) SE Runtime Environment (build 1.6.0_14-b08). The JDBC driver
is mysql-connector-java-5.1.14-bin.jar. The database is mysql-server-5.0.77-4.el5_4.2.
> 
> It becomes master, but never registers it's brokerName in the database. I can submit
persistent messages and the successfully get logged in ACTIVEMQ_MSGS. The entire schema was
created automatically by ActiveMQ. 
> 
> 2010-12-17 20:34:51,793 | INFO  | Attempting to acquire the exclusive lock to become
the Master broker | org.apache.activemq.store.jdbc.DefaultDatabaseLocker | main
> 2010-12-17 20:34:51,810 | INFO  | Becoming the master on dataSource: org.apache.commons.dbcp.BasicDataSource@3b1f38
| org.apache.activemq.store.jdbc.DefaultDatabaseLocker | main
> 
> mysql> select * from ACTIVEMQ_LOCK;
> +----+------+-------------+
> | ID | TIME | BROKER_NAME |
> +----+------+-------------+
> |  1 | NULL | NULL        | 
> +----+------+-------------+
> 1 row in set (0.00 sec)
> 
> mysql> select count(*) from ACTIVEMQ_MSGS;
> +----------+
> | count(*) |
> +----------+
> |     1000 | 
> +----------+
> 1 row in set (0.00 sec)
> 
> 
> The brokerName has been set in the running configuration for the <broker/>.
> <broker xmlns="http://activemq.apache.org/schema/core" brokerName="ec2-174-129-179-24.compute-1.amazonaws.com"
dataDirectory="${activemq.base}/data" destroyApplicationContextOnStop="true" persistent="true"
useShutdownHook="false" useJmx="true">
> 
> I have also tried adding -Dactivemq.hostname=ec2-174-129-179-24.compute-1.amazonaws.com
to the init script, but it doesn't have any affect either.
> 
> Complete configuration below.
> 
> Any input greatly appreciated!
> 
> 
> Erik Osterman
> <e@osterman.com>
> http://www.osterman.com
> 
> 
> 
> 
> 
> <beans
>  xmlns="http://www.springframework.org/schema/beans"
>  xmlns:amq="http://activemq.apache.org/schema/core"
>  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.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.base}/conf/credentials.properties</value>
>    </property>      
>  </bean>
> 
>  <broker xmlns="http://activemq.apache.org/schema/core" brokerName="ec2-174-129-179-24.compute-1.amazonaws.com"
dataDirectory="${activemq.base}/data" destroyApplicationContextOnStop="true" persistent="true"
useShutdownHook="false" useJmx="true">
>    <managementContext>
>      <managementContext createConnector="false"/>
>    </managementContext>
> 
>    <networkConnectors>
>      <networkConnector uri="multicast://default"/>
>    </networkConnectors>
> 
> 
>    <persistenceAdapter>
>      <jdbcPersistenceAdapter dataDirectory="${activemq.base}/data" dataSource="#mysql-ds"
/>
>    </persistenceAdapter>
> 
>    <plugins>
>      <statisticsBrokerPlugin/>
>    </plugins>
> 
>    <systemUsage>
>      <systemUsage>
>        <memoryUsage>
>          <memoryUsage limit="20 mb"/>
>        </memoryUsage>
>        <storeUsage>
>          <storeUsage limit="1 gb"/>
>        </storeUsage>
>        <tempUsage>
>          <tempUsage limit="100 mb"/>
>        </tempUsage>
>      </systemUsage>
>    </systemUsage>
> 
>    <transportConnectors>
>      <!-- <transportConnector name="openwire" uri="tcp://0.0.0.0:61616"/> -->
>      <transportConnector name="stomp" uri="stomp://0.0.0.0:61612?transport.closeAsync=false"/>

>      <transportConnector name="stomp+nio" uri="stomp+nio://0.0.0.0:61613?transport.closeAsync=false"/>

>    </transportConnectors>
> 
>  </broker>
> 
>  <import resource="jetty.xml"/>
> 
>  <bean id="mysql-ds" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
>    <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
>    <property name="url" value="jdbc:mysql://localhost/activemq?relaxAutoCommit=true"/>
>    <property name="username" value="activemq"/>
>    <property name="password" value="activemq"/>
>    <property name="maxActive" value="200"/>
>    <property name="poolPreparedStatements" value="true"/>
>  </bean>
> 
> </beans>
> 
> 
> 
> 
> 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message