ActiveMQ基本教程 ActiveMQ持久化 ActiveMQ安全
一:快速上手1:官方网站下载最新版本,当前最新为5.9.0
2:解压后,打开cmd,进入bin目录,执行:activemq,即可启动。(linux下,输入nohup activemq &)
注意看打出的启动日志。
Loading message broker from: xbean:activemq.xml,这个文件是主要的配置文件。
Using Persistence Adapter: KahaDBPersistenceAdapter,这是一个activemq专用的消息存储器,速度很快的。
Listening for connections at: tcp://collonn-PC:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600,这是activemq监听的其中一个端口。
ActiveMQ WebConsole available at http://localhost:8161/,这是activemq基于页面的控制台。
3:打开浏览器,输入http://localhost:8161/,选择Manage ActiveMQ broker using the old console,用旧的方式查看和控制activemq更方便。
二:快速进阶
1:进入到activemq_install_dir/config目录,有以下几个重要文件
(1)activemq.xml,在此文件中你可以配置activemq的很多东西,比如将消息持久化到数据库等。
(2)credentials.properties,一些密码,多用于生产和消费的密码认证。
(3)jetty.xml,activemq内置了jetty应用服务器。
(4)jetty-realm.properties,activemq控制台登陆密码。
三:持久化消息到MySQL
1:activemq_install_dir/examples/config目录下有好多示例配置文件可以做参考,如持久化到数据库,安全相关等。
2:将mysql驱动拷贝到activemq_install_dir/lib目录下,并在数据库中创建一个空的数据空的数据库,名称为activemq。
3:修改activemq.xml文件,如下
[html]
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!--
Use JDBC for message persistence
For more information, see:
http://activemq.apache.org/persistence.html
You need to add Derby database to your classpath in order to make this example work.
Download it from http://db.apache.org/derby/ and put it in the ${ACTIVEMQ_HOME}/lib/optional/ folder
Optionally you can configure any other RDBM as shown below
To run ActiveMQ with this configuration add xbean:examples/conf/activemq-jdbc.xml to your command
e.g. $ bin/activemq console xbean:examples/conf/activemq-jdbc.xml
-->
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
<!-- Allows us to use system properties as variables in this configuration file -->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>file:${activemq.conf}/credentials.properties</value>
</property>
</bean>
<broker useJmx="false" brokerName="jdbcBroker" xmlns="http://activemq.apache.org/schema/core">
<!--
See more database locker options at http://activemq.apache.org/pluggable-storage-lockers.html
-->
<persistenceAdapter>
<jdbcPersistenceAdapter dataDirectory="${activemq.data}" dataSource="#mysql-ds"/>
</persistenceAdapter>
<transportConnectors>
<transportConnector name="openwire" uri="tcp://0.0.0.0:61616"/>
</transportConnectors>
</broker>
<!-- Embedded Derby DataSource Sample Setup -->
<!--
<bean id="derby-ds" class="org.apache.derby.jdbc.EmbeddedDataSource">
<property name="databaseName" value="derbydb"/>
<property name="createDatabase" value="create"/>
</bean>
-->
<!-- Postgres DataSource Sample Setup -->
<!--
<bean id="postgres-ds" class="org.postgresql.ds.PGPoolingDataSource">
<property name="serverName" value="localhost"/>
<property name="databaseName" value="activemq"/>
<property name="portNumber" value="0"/>
<property name="user" value="activemq"/>
<property name="password" value="activemq"/>
<property name="dataSourceName" value="postgres"/>
<property name="initialConnections" value="1"/>
<property name="maxConnections" value="10"/>
</bean>
-->
<!-- MySql DataSource Sample Setup -->
<bean id="mysql-ds" class="org.apache.commons.dbcp.BasicDataSource" destroy-method=&qu
补充:软件开发 , Java ,
- 更多JAVA疑问解答:
- java怎么在线读取ftp服务器上的文件内容
- 关于程序员的职业规划
- HTML和JSP矛盾吗?
- java小程序如何打包?
- java怎么split路径文件名?
- jsp+javaBean中Column 'ordersPrice' specified twice的错误
- Java TCP/IP Socket网络编程系列
- 大家来讨论一下我到底该用什么好?Swing 还是 JavaFX
- 关于Hibernate实体自身多对一的抓取问题
- 关于apache2+tomcat群集出现的问题
- spring 获取上下文问题
- SSH 导入导出excel 谁有这块的资料吗?
- Ext TreePanel 刷新问题
- springmvc 加载一个jsp页面执行多个方法 报404
- checkbox数组action怎么向页面传值