一、下载windows压缩包

解压并双击F:\server\activemq-5.13.2\bin\win64\activemq.bat 启动,32位的系统为F:\server\activemq-5.13.2\bin\win32\activemq.bat;

二、配置访问权限

编辑F:\server\activemq-5.13.2\conf\activemq.xml 文件,

添加plugins节点:

<broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="${activemq.data}">

     <plugins>
<simpleAuthenticationPlugin>
<users>
<authenticationUser username="system" password="123" groups="users,admins"/>
<authenticationUser username="user" password="321" groups="users"/>
<authenticationUser username="guest" password="111" groups="guests"/>
</users>
</simpleAuthenticationPlugin>
</plugins> <destinationPolicy>
<policyMap>
<policyEntries>
<policyEntry topic=">" >
<!-- The constantPendingMessageLimitStrategy is used to prevent
slow topic consumers to block producers and affect other consumers
by limiting the number of messages that are retained
For more information, see: http://activemq.apache.org/slow-consumer-handling.html -->
<pendingMessageLimitStrategy>
<constantPendingMessageLimitStrategy limit="1000"/>
</pendingMessageLimitStrategy>
</policyEntry>
</policyEntries>
</policyMap>
</destinationPolicy> <!--
The managementContext is used to configure how ActiveMQ is exposed in
JMX. By default, ActiveMQ uses the MBean server that is started by
the JVM. For more information, see: http://activemq.apache.org/jmx.html
-->
<managementContext>
<managementContext createConnector="false"/>
</managementContext> <!--
Configure message persistence for the broker. The default persistence
mechanism is the KahaDB store (identified by the kahaDB tag).
For more information, see: http://activemq.apache.org/persistence.html
-->
<persistenceAdapter>
<kahaDB directory="${activemq.data}/kahadb"/>
</persistenceAdapter> <!--
The systemUsage controls the maximum amount of space the broker will
use before disabling caching and/or slowing down producers. For more information, see:
http://activemq.apache.org/producer-flow-control.html
-->
<systemUsage>
<systemUsage>
<memoryUsage>
<memoryUsage percentOfJvmHeap="70" />
</memoryUsage>
<storeUsage>
<storeUsage limit="100 gb"/>
</storeUsage>
<tempUsage>
<tempUsage limit="50 gb"/>
</tempUsage>
</systemUsage>
</systemUsage> <!--
The transport connectors expose ActiveMQ over a given protocol to
clients and other brokers. For more information, see: http://activemq.apache.org/configuring-transports.html
-->
<transportConnectors>
<!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
<transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
<transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
<transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
<transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
<transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
</transportConnectors> <!-- destroy the spring context on shutdown to stop jetty -->
<shutdownHooks>
<bean xmlns="http://www.springframework.org/schema/beans" class="org.apache.activemq.hooks.SpringContextHook" />
</shutdownHooks> </broker>

三、访问http://localhost:8161/控制台;

四、示例代码:

package activemq;

import java.io.Serializable;

public class User implements Serializable {

    private static final long serialVersionUID = 1L;
private int id;
private String name;
private String pass; public User(int id, String name, String pass){
this.id = id;
this.name = name;
this.pass = pass;
} public int getId() {
return id;
} public void setId(int id) {
this.id = id;
} public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} public String getPass() {
return pass;
} public void setPass(String pass) {
this.pass = pass;
} }
package activemq;

import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.DeliveryMode;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.ObjectMessage;
import javax.jms.Session; import org.apache.activemq.ActiveMQConnectionFactory; public class JmsSender { public void send() {
ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
"tcp://127.0.0.1:61616"); try {
Connection connection = connectionFactory.createConnection("user", "321");
connection.start(); Session session = connection.createSession(Boolean.TRUE,
Session.AUTO_ACKNOWLEDGE);
Destination destination = session.createQueue("Test4.foo"); MessageProducer producer = session.createProducer(destination);
producer.setDeliveryMode(DeliveryMode.PERSISTENT);
for (int i = 0; i < 100; i++) {
int id = i + 1;
ObjectMessage message = session.createObjectMessage();
message.setObject(new User(id, "李四" + id, "123456")); /**
//文本消息
TextMessage textMessage = session.createTextMessage("文本消息"); //键值对消息
MapMessage mapMessage = session.createMapMessage();
mapMessage.setLong("age", new Long(32));
mapMessage.setDouble("sarray", new Double(5867.15));
mapMessage.setString("username", "键值对消息"); //流消息
StreamMessage streamMessage = session.createStreamMessage();
streamMessage.writeString("streamMessage流消息");
streamMessage.writeLong(55); //字节消息
String s = "BytesMessage字节消息";
BytesMessage bytesMessage = session.createBytesMessage();
bytesMessage.writeBytes(s.getBytes());
**/ producer.send(message);
}
session.commit();
session.close();
connection.close();
} catch (JMSException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} public static void main(String[] args){
new JmsSender().send();
}
}
package activemq;

import java.util.concurrent.TimeUnit;

import javax.jms.BytesMessage;
import javax.jms.Connection;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MapMessage;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageListener;
import javax.jms.ObjectMessage;
import javax.jms.Session;
import javax.jms.StreamMessage;
import javax.jms.TextMessage; import org.apache.activemq.ActiveMQConnectionFactory; public class JmsReceiver { public static void main(String[] args) {
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
"tcp://127.0.0.1:61616");
connectionFactory.setTrustAllPackages(true); try {
Connection connection = connectionFactory.createConnection("guest",
"111");
connection.start(); final Session session = connection.createSession(Boolean.TRUE,
Session.AUTO_ACKNOWLEDGE);
Destination destination = session.createQueue("Test4.foo"); MessageConsumer consumer = session.createConsumer(destination);
// listener 方式
consumer.setMessageListener(new MessageListener() { public void onMessage(Message msg) {
ObjectMessage message = (ObjectMessage) msg;
// TODO something....
try {
User user = (User) message.getObject();
System.out.println("收到消息:" + user.getName());
} catch (JMSException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
session.commit();
} catch (JMSException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} });
TimeUnit.MINUTES.sleep(1); session.close();
connection.close();
} catch (JMSException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} public void onMessage(Message m) {
try {
if (m instanceof TextMessage) { // 接收文本消息
TextMessage message = (TextMessage) m;
System.out.println(message.getText());
} else if (m instanceof MapMessage) { // 接收键值对消息
MapMessage message = (MapMessage) m;
System.out.println(message.getLong("age"));
System.out.println(message.getDouble("sarray"));
System.out.println(message.getString("username"));
} else if (m instanceof StreamMessage) { // 接收流消息
StreamMessage message = (StreamMessage) m;
System.out.println(message.readString());
System.out.println(message.readLong());
} else if (m instanceof BytesMessage) { // 接收字节消息
byte[] b = new byte[1024];
int len = -1;
BytesMessage message = (BytesMessage) m;
while ((len = message.readBytes(b)) != -1) {
System.out.println(new String(b, 0, len));
}
} else if (m instanceof ObjectMessage) { // 接收对象消息
ObjectMessage message = (ObjectMessage) m;
User user = (User) message.getObject();
} else {
System.out.println(m);
} } catch (JMSException e) { e.printStackTrace();
}
} }

activemq-5.13 在windows下部署应用的更多相关文章

  1. windows 下部署kafka 日记 转

    windows 下部署kafka 日记 转一.下载去apache 的官网(http://kafka.apache.org/downloads.html)下载最新的二进制版的压缩包.目前的最新版本是ka ...

  2. QT程序在windows下部署发布

    转载:http://www.cnblogs.com/Fan_Fan/archive/2010/05/29/1746860.html QT程序在windows下部署发布 以下包括了部分网上收集的,以及q ...

  3. Windows下部署ElasticSearch5.0以下版本

    Windows下部署ElasticSearch分ElasticSearch5.0以上版本(包括5.0)和ElasticSearch5.0以下版本两种情况,这两种安装方式有很大不同.今天首先说Elast ...

  4. 关于在windows下部署发布QT程序的总结

    原文请看:http://www.cnblogs.com/javaexam2/archive/2011/05/18/2632916.html 关于在windows下部署发布QT程序的总结 2008-06 ...

  5. linux centos7 和 windows下 部署 .net core 2.0 web应用

    centos7 下部署asp.net core 2.0应用 安装CentOS7 配置网络[可选] 安装.Net core2.0 创建测试Asp.net Core应用程序 正式部署项目 安装VMware ...

  6. windows 下部署 .netcore 到 docker

    前面我们演示了如何将 Asp.Net Core 程序部署到 iis 和 部署到 windows 服务.其实前面的都是铺垫,如何将 Asp.Net Core 站点部署到 docker 才是这个系列文章的 ...

  7. windows 下部署 .netcore 到 windows service

    接上一篇 <windows 下部署 .netcore 到 iis>,这一篇记录一下怎么将 Asp.Net Core 以 windows 服务的方式部署. 一.修改代码 其实也很简单,只要调 ...

  8. 使用Vagrant在Windows下部署开发环境

    做Web开发少不了要在本地搭建好开发环境,虽然说目前各种脚本都有对应的Windows版,甚至是一键安装包,但很多时候和Windows环境的相性并不是那么好,各麻烦的问题是实际部署的环境通常是Linux ...

  9. 关于Linux和Windows下部署mysql.data.dll的注册问题

    mysql ado.net connector下载地址: http://dev.mysql.com/downloads/connector/net/ 选择版本: Generally Available ...

随机推荐

  1. sgu 107 987654321 problem

    其实挺水的,因为两个数平方,只有固定的后面几位数会影响到最后结果的后面几位数.也就是说,如果想在平方之后尾数为987654321,那么就有固定的几个尾数在平方后会是这个数,打个表,发现 10^8 内 ...

  2. Poj 2159 / OpenJudge 2159 Ancient Cipher

    1.链接地址: http://poj.org/problem?id=2159 http://bailian.openjudge.cn/practice/2159 2.题目: Ancient Ciphe ...

  3. 使用AutoMapper

    一.AutoMapper初探: [参考Using AutoMapper: Getting Started] 1.新建空的ASP.NET MVC项目. 2.在Models文件夹添加类: public c ...

  4. Windows Phone 动态改变ListBox样式

    使用ListBox时通常会借助ItemTemplate帮助我们实现更复杂多样的样式显示,体现了Xaml的灵活.如何动态改变变ListBox的样式,实现类似电脑资源管理器中列表显示和图标显示形式的替换. ...

  5. debian 学习记录-4 -关于linux -2

    来源:<Debian标准教程>王旭 著 Slackware.Debian.RedHat.SuSE 这4种发布版是当今大部分发布版的前去,虽然SuSE衍生自Slackware,但由于其技术变 ...

  6. RX学习笔记:FreeCodeCamp的JavaScript基本算法挑战

    FreeCodeCamp的JavaScript基本算法挑战 https://www.freecodecamp.com 2016-07-03 JavaScript还不是非常熟悉,用已经会的知识来解这些题 ...

  7. C#对word、excel、pdf等格式文件的操作总结

    一.word 这是我以前工作时写过的一个业务逻辑处理类,里面有不少文件操作的方法,这里主要关注一下C#对word的操作.里面的方法可以直接拿出来用,主要是通过word的dot模版来进行创建word.替 ...

  8. LPC17XX 数据手册摘要之系统时钟与功率控制

    系统时钟与功率控制 一.系统时钟 LPC17XX有三个独立的时钟振荡器,分别是主振荡器(MIAN_OSC).内部RC振荡器(IRC_OSC).实时时钟振荡器(RTC_OSC).LPC17XX时钟框图如 ...

  9. JS 获取 路径参数 传入 参数名 截取 & 和 # 之前 字符

    function getQueryStringByName(name) { var result = location.search.match(new RegExp("[\?\&] ...

  10. thinkphp验证码的实现

    两种验证码验证实现,一种直接在form表单提交按钮实现验证,一种使用ajax传递参数实现验证: 1.直接在form表单提交按钮实现验证,在控制器VerifyController.class.php中写 ...