activeMQ Mysql静态话

来源:互联网 发布:js cookie大小 编辑:程序博客网 时间:2024/05/19 14:36

在activemq.xml文件中找到<persistenceAdapter>节点,修改如下:

<persistenceAdapter>    <jdbcPersistenceAdapter dataSource="#MySQL-DS" createTablesOnStartup="false"/></persistenceAdapter><!--createTablesOnStartup第一次启动时设置成true,然后设置成false后面就不需要每次启动都去建表了.-->

MySQL-DS的定义:

<!--在配置文件中的broker节点外增加如下内容--><bean id="MySQL-DS" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close">    <property name="driverClassName" value="com.mysql.jdbc.Driver"/>    <property name="url" value="jdbc:mysql://x.x.x.x:3306/xxxx?relaxAutoCommit=true"/>    <property name="username" value="xxxx"/>    <property name="password" value="xxxx"/>    <property name="poolPreparedStatements" value="true"/> </bean>

最后把mysql-connector-java.jar、druid.jar拷贝到lib文件夹下,再新建数据库就可以了.

activemq默认是不需要密码的,不管生产还是消费都可以直接连接,如果如果加入验证需要在activemq.xml中添加plugins节点内容如下:

<plugins>    <!-- Configure authentication; Username, passwords and groups -->    <simpleAuthenticationPlugin>        <users>            <authenticationUser username="${activemq.username}" password="${activemq.password}"   groups="users,admins"/>        </users>    </simpleAuthenticationPlugin></plugins>

这样就可以验证了,用户名和密码在activemq/conf/credentials.properties中配置

0 0
原创粉丝点击