网上的教程使用的都是 org.apache.commons.dbcp.BasicDataSource来作为数据库数据源,需要下载DBCP + mysql-connector jar包放到activemq/lib目录下,
并在数据库创建activemq 所需要的表。(脚本在文章尾部)
启动时却报 org.apache.commons.dbcp.BasicDataSource ClassNotFound
原因从DBCP官网下载最新的BasicDataSouce所属的包名为dbcp2 而不是dbcp,所以改完bean 的class 为 org.apache.commons.dbcp2.BasicDataSource就可以正常运行了。
另外调试方式可以使用 console 来进行调试。
DROP TABLE IF EXISTS ACTIVEMQ_ACKS
;
CREATE TABLE ACTIVEMQ_ACKS
(
CONTAINER
varchar(250) COLLATE latin1_bin NOT NULL,
SUB_DEST
varchar(250) COLLATE latin1_bin DEFAULT NULL,
CLIENT_ID
varchar(250) COLLATE latin1_bin NOT NULL,
SUB_NAME
varchar(250) COLLATE latin1_bin NOT NULL,
SELECTOR
varchar(250) COLLATE latin1_bin DEFAULT NULL,
LAST_ACKED_ID
bigint(20) DEFAULT NULL,
PRIORITY
bigint(20) NOT NULL DEFAULT '5',
XID
varchar(250) COLLATE latin1_bin DEFAULT NULL,
PRIMARY KEY (CONTAINER
,CLIENT_ID
,SUB_NAME
,PRIORITY
),
KEY ACTIVEMQ_ACKS_XIDX
(XID
)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_bin;
/*Table structure for table ACTIVEMQ_LOCK
*/
DROP TABLE IF EXISTS ACTIVEMQ_LOCK
;
CREATE TABLE ACTIVEMQ_LOCK
(
ID
bigint(20) NOT NULL,
TIME
bigint(20) DEFAULT NULL,
BROKER_NAME
varchar(250) COLLATE latin1_bin DEFAULT NULL,
PRIMARY KEY (ID
)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_bin;
/*Table structure for table ACTIVEMQ_MSGS
*/
DROP TABLE IF EXISTS ACTIVEMQ_MSGS
;
CREATE TABLE ACTIVEMQ_MSGS
(
ID
bigint(20) NOT NULL,
CONTAINER
varchar(250) COLLATE latin1_bin DEFAULT NULL,
MSGID_PROD
varchar(250) COLLATE latin1_bin DEFAULT NULL,
MSGID_SEQ
bigint(20) DEFAULT NULL,
EXPIRATION
bigint(20) DEFAULT NULL,
MSG
longblob,
PRIORITY
bigint(20) DEFAULT NULL,
XID
varchar(250) COLLATE latin1_bin DEFAULT NULL,
PRIMARY KEY (ID
),
KEY ACTIVEMQ_MSGS_MIDX
(MSGID_PROD
,MSGID_SEQ
),
KEY ACTIVEMQ_MSGS_CIDX
(CONTAINER
),
KEY ACTIVEMQ_MSGS_EIDX
(EXPIRATION
),
KEY ACTIVEMQ_MSGS_PIDX
(PRIORITY
),
KEY ACTIVEMQ_MSGS_XIDX
(XID
)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_bin;