无情 @ Mon May 04 15:19:37 CST 2015 阅读(1614)
activemq_acks Activemq




1.添加MySql数据源

       打开Activemq安装目录下的conf/activemq.xml文件,添加MySql数据源。默认情况下Activemq使用KahaDB存储,注解掉KahaDB配置,改为mysql配置如下:

 

   


 

该配置表示,我们将要使用名称为“MySQL-DS”的作为mysql数据源。


2. 配置MySql数据源

      在节点后面,增加MySQL数据源配置:

 

   

   

   

   

   



3. 创建数据库activemq  字符集需要使用latin1 



4. 配置完成后,将mysql-connector-java-5.1.29.jar 驱动包加入到 Activemq 的 lib目录下,启动Activemq。查看activemq数据库会有三张表:activemq_acks  ,activemq_lock  ,activemq_msgs 

数据表activemq_msgs即为持久化消息表;




注意可能出现异常(创建数据库activemq  字符集需要使用latin1   否者出现下面错误)

2015-05-04 14:50:30,335 | INFO  | Refreshing org.apache.activemq.xbean.XBeanBrokerFactory$1@30f97aff: startup date [Mon May 04 14:50:30 CST 2015]; root of context hierarchy | org.apache.activemq.xbean.XBeanBrokerFactory$1 | WrapperSimpleAppMain
2015-05-04 14:50:33,051 | INFO  | PListStore:[/usr/local/apache-activemq-5.11.1/bin/linux-x86-64/../../data/localhost/tmp_storage] started | org.apache.activemq.store.kahadb.plist.PListStoreImpl | WrapperSimpleAppMain
2015-05-04 14:50:33,134 | INFO  | Using Persistence Adapter: JDBCPersistenceAdapter(org.apache.commons.dbcp.BasicDataSource@74aad738) | org.apache.activemq.broker.BrokerService | WrapperSimpleAppMain
2015-05-04 14:50:33,509 | INFO  | Database adapter driver override recognized for : [mysql_connector_java] - adapter: class org.apache.activemq.store.jdbc.adapter.MySqlJDBCAdapter | org.apache.activemq.store.jdbc.JDBCPersistenceAdapter | WrapperSimpleAppMain
2015-05-04 14:50:33,575 | INFO  | Database lock driver override not found for : [mysql_connector_java].  Will use default implementation. | org.apache.activemq.store.jdbc.JDBCPersistenceAdapter | WrapperSimpleAppMain
2015-05-04 14:50:33,578 | INFO  | Using a separate dataSource for locking: org.apache.commons.dbcp.BasicDataSource@74aad738 | org.apache.activemq.store.jdbc.JDBCPersistenceAdapter | WrapperSimpleAppMain
2015-05-04 14:50:33,580 | INFO  | Attempting to acquire the exclusive lock to become the Master broker | org.apache.activemq.store.jdbc.DefaultDatabaseLocker | WrapperSimpleAppMain
2015-05-04 14:50:33,602 | INFO  | Becoming the master on dataSource: org.apache.commons.dbcp.BasicDataSource@74aad738 | org.apache.activemq.store.jdbc.DefaultDatabaseLocker | WrapperSimpleAppMain
2015-05-04 14:50:33,642 | WARN  | Old message cleanup failed due to: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'activemq.activemq_acks' doesn't exist | org.apache.activemq.store.jdbc.JDBCPersistenceAdapter | ActiveMQ JDBC PA Scheduled Task
2015-05-04 14:50:33,645 | WARN  | Failure Details: Table 'activemq.activemq_acks' doesn't exist | org.apache.activemq.store.jdbc.JDBCPersistenceAdapter | ActiveMQ JDBC PA Scheduled Task
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'activemq.activemq_acks' doesn't exist
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)[:1.7.0_79]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)[:1.7.0_79]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)[:1.7.0_79]
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)[:1.7.0_79]
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)[mysql-connector-java-5.1.29.jar:]
at com.mysql.jdbc.Util.getInstance(Util.java:386)[mysql-connector-java-5.1.29.jar:]
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)[mysql-connector-java-5.1.29.jar:]
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4237)[mysql-connector-java-5.1.29.jar:]
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4169)[mysql-connector-java-5.1.29.jar:]
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2617)[mysql-connector-java-5.1.29.jar:]
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2778)[mysql-connector-java-5.1.29.jar:]
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2834)[mysql-connector-java-5.1.29.jar:]
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2156)[mysql-connector-java-5.1.29.jar:]
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2441)[mysql-connector-java-5.1.29.jar:]
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2366)[mysql-connector-java-5.1.29.jar:]
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2350)[mysql-connector-java-5.1.29.jar:]
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)[commons-dbcp-1.4.jar:1.4]
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)[commons-dbcp-1.4.jar:1.4]
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)[commons-dbcp-1.4.jar:1.4]
at org.apache.activemq.store.jdbc.adapter.DefaultJDBCAdapter.doDeleteOldMessages(DefaultJDBCAdapter.java:856)[activemq-jdbc-store-5.11.1.jar:5.11.1]
at org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.cleanup(JDBCPersistenceAdapter.java:346)[activemq-jdbc-store-5.11.1.jar:5.11.1]
at org.apache.activemq.store.jdbc.JDBCPersistenceAdapter$3.run(JDBCPersistenceAdapter.java:326)[activemq-jdbc-store-5.11.1.jar:5.11.1]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)[:1.7.0_79]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304)[:1.7.0_79]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)[:1.7.0_79]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)[:1.7.0_79]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[:1.7.0_79]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[:1.7.0_79]
at java.lang.Thread.run(Thread.java:745)[:1.7.0_79]
2015-05-04 14:50:33,746 | WARN  | JDBC Failure: Table 'activemq.activemq_acks' doesn't exist | org.apache.activemq.store.jdbc.JDBCPersistenceAdapter | WrapperSimpleAppMain
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'activemq.activemq_acks' doesn't exist
at sun.reflect.GeneratedConstructorAccessor3.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)[:1.7.0_79]
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)[:1.7.0_79]
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)[mysql-connector-java-5.1.29.jar:]
at com.mysql.jdbc.Util.getInstance(Util.java:386)[mysql-connector-java-5.1.29.jar:]
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)[mysql-connector-java-5.1.29.jar:]
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4237)[mysql-connector-java-5.1.29.jar:]
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4169)[mysql-connector-java-5.1.29.jar:]
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2617)[mysql-connector-java-5.1.29.jar:]
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2778)[mysql-connector-java-5.1.29.jar:]
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2834)[mysql-connector-java-5.1.29.jar:]
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2156)[mysql-connector-java-5.1.29.jar:]
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2313)[mysql-connector-java-5.1.29.jar:]
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)[commons-dbcp-1.4.jar:1.4]
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)[commons-dbcp-1.4.jar:1.4]
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)[commons-dbcp-1.4.jar:1.4]
at org.apache.activemq.store.jdbc.adapter.DefaultJDBCAdapter.doGetLastMessageStoreSequenceId(DefaultJDBCAdapter.java:184)[activemq-jdbc-store-5.11.1.jar:5.11.1]
at org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.getLastMessageBrokerSequenceId(JDBCPersistenceAdapter.java:260)[activemq-jdbc-store-5.11.1.jar:5.11.1]
at org.apache.activemq.broker.region.DestinationFactoryImpl.getLastMessageBrokerSequenceId(DestinationFactoryImpl.java:147)[activemq-broker-5.11.1.jar:5.11.1]
at org.apache.activemq.broker.region.RegionBroker.(RegionBroker.java:130)[activemq-broker-5.11.1.jar:5.11.1]
at org.apache.activemq.broker.jmx.ManagedRegionBroker.(ManagedRegionBroker.java:112)[activemq-broker-5.11.1.jar:5.11.1]
at org.apache.activemq.broker.BrokerService.createRegionBroker(BrokerService.java:2264)[activemq-broker-5.11.1.jar:5.11.1]
at org.apache.activemq.broker.BrokerService.createRegionBroker(BrokerService.java:2257)[activemq-broker-5.11.1.jar:5.11.1]
at org.apache.activemq.broker.BrokerService.createBroker(BrokerService.java:2214)[activemq-broker-5.11.1.jar:5.11.1]
at org.apache.activemq.broker.BrokerService.getBroker(BrokerService.java:967)[activemq-broker-5.11.1.jar:5.11.1]
at org.apache.activemq.broker.BrokerService.getAdminConnectionContext(BrokerService.java:2485)[activemq-broker-5.11.1.jar:5.11.1]
at org.apache.activemq.broker.BrokerService.startVirtualConsumerDestinations(BrokerService.java:2625)[activemq-broker-5.11.1.jar:5.11.1]
at org.apache.activemq.broker.BrokerService.startDestinations(BrokerService.java:2476)[activemq-broker-5.11.1.jar:5.11.1]
at org.apache.activemq.broker.BrokerService.doStartBroker(BrokerService.java:678)[activemq-broker-5.11.1.jar:5.11.1]
at org.apache.activemq.broker.BrokerService.startBroker(BrokerService.java:670)[activemq-broker-5.11.1.jar:5.11.1]
at org.apache.activemq.broker.BrokerService.start(BrokerService.java:606)[activemq-broker-5.11.1.jar:5.11.1]
at org.apache.activemq.xbean.XBeanBrokerService.afterPropertiesSet(XBeanBrokerService.java:73)[activemq-spring-5.11.1.jar:5.11.1]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.7.0_79]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_79]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_79]
at java.lang.reflect.Method.invoke(Method.java:606)[:1.7.0_79]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1640)[spring-beans-3.2.11.RELEASE.jar:3.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1581)[spring-beans-3.2.11.RELEASE.jar:3.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1511)[spring-beans-3.2.11.RELEASE.jar:3.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)[spring-beans-3.2.11.RELEASE.jar:3.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)[spring-beans-3.2.11.RELEASE.jar:3.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)[spring-beans-3.2.11.RELEASE.jar:3.2.11.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)[spring-beans-3.2.11.RELEASE.jar:3.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)[spring-beans-3.2.11.RELEASE.jar:3.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:191)[spring-beans-3.2.11.RELEASE.jar:3.2.11.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:636)[spring-beans-3.2.11.RELEASE.jar:3.2.11.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:934)[spring-context-3.2.11.RELEASE.jar:3.2.11.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)[spring-context-3.2.11.RELEASE.jar:3.2.11.RELEASE]
at org.apache.xbean.spring.context.ResourceXmlApplicationContext.(ResourceXmlApplicationContext.java:64)[xbean-spring-3.18.jar:3.18]
at org.apache.xbean.spring.context.ResourceXmlApplicationContext.(ResourceXmlApplicationContext.java:52)[xbean-spring-3.18.jar:3.18]
at org.apache.activemq.xbean.XBeanBrokerFactory$1.(XBeanBrokerFactory.java:104)[activemq-spring-5.11.1.jar:5.11.1]
at org.apache.activemq.xbean.XBeanBrokerFactory.createApplicationContext(XBeanBrokerFactory.java:104)[activemq-spring-5.11.1.jar:5.11.1]
at org.apache.activemq.xbean.XBeanBrokerFactory.createBroker(XBeanBrokerFactory.java:67)[activemq-spring-5.11.1.jar:5.11.1]
at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.java:71)[activemq-broker-5.11.1.jar:5.11.1]
at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.java:54)[activemq-broker-5.11.1.jar:5.11.1]
at org.apache.activemq.console.command.StartCommand.runTask(StartCommand.java:87)[activemq-console-5.11.1.jar:5.11.1]
at org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:57)[activemq-console-5.11.1.jar:5.11.1]
at org.apache.activemq.console.command.ShellCommand.runTask(ShellCommand.java:150)[activemq-console-5.11.1.jar:5.11.1]
at org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:57)[activemq-console-5.11.1.jar:5.11.1]
at org.apache.activemq.console.command.ShellCommand.main(ShellCommand.java:104)[activemq-console-5.11.1.jar:5.11.1]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.7.0_79]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_79]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_79]
at java.lang.reflect.Method.invoke(Method.java:606)[:1.7.0_79]
at org.apache.activemq.console.Main.runTaskClass(Main.java:262)[activemq.jar:5.11.1]
at org.apache.activemq.console.Main.main(Main.java:115)[activemq.jar:5.11.1]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.7.0_79]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_79]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_79]
at java.lang.reflect.Method.invoke(Method.java:606)[:1.7.0_79]
at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:240)[wrapper.jar:3.2.3]
at java.lang.Thread.run(Thread.java:745)[:1.7.0_79]