網(wǎng)上的教程使用的都是 org.apache.commons.dbcp.BasicDataSource來作為數(shù)據(jù)庫數(shù)據(jù)源,需要下載DBCP + mysql-connector jar包放到activemq/lib目錄下,
并在數(shù)據(jù)庫創(chuàng)建activemq 所需要的表伦糯。(腳本在文章尾部)
啟動時卻報 org.apache.commons.dbcp.BasicDataSource ClassNotFound
原因從DBCP官網(wǎng)下載最新的BasicDataSouce所屬的包名為dbcp2 而不是dbcp翅雏,所以改完bean 的class 為 org.apache.commons.dbcp2.BasicDataSource就可以正常運(yùn)行了。
另外調(diào)試方式可以使用 console 來進(jìn)行調(diào)試。
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;