第一步:
activemq.xml文件里添加
- <plugins>
- <simpleAuthenticationPlugin>
- <users>
- <authenticationUser username="${activemq.username}" password="${activemq.password}" groups="users,admins"/>
- </users>
- </simpleAuthenticationPlugin>
- </plugins>
- <persistenceAdapter>
- <jdbcPersistenceAdapter dataDirectory="${activemq.base}/data" dataSource="#db2-ds"/>
- </persistenceAdapter>
- <bean id="db2-ds" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
- <property name="driverClassName" value="com.ibm.db2.jcc.DB2Driver"/>
- <property name="url" value="jdbc:db2://10.176.168.13:50000/activemq:retrieveMessagesFromServerOnGetMessage=true;"/>
- <property name="username" value="db2inst1"/>
- <property name="password" value="passw0rd"/>
- <property name="maxActive" value="200"/>
- <property name="poolPreparedStatements" value="true"/>
- </bean>
第二步:
相关的jar包
db2jcc.jar
commons-pool-1.5.4.jar
commons-dbcp-1.2.2.jar
commons-collections-3.2.1.jar
第三步:
(1)sender、receiver里,构造ConnectionFactory实例对象时,使用
- connectionFactory = new ActiveMQConnectionFactory(
- "test",
- "123456", "tcp://10.176.160.8:61616");
(2)sender里,设置持久化,使用
- producer.setDeliveryMode(DeliveryMode.PERSISTENT);
第四步:
注意事项
在activemq.xml里,注入一些节点的时候,注意顺序,否则,启动时可能会引起解析xml的异常