从http://activemq.apache.org/activemq-5132-release.html 下载

解压

从apache-activemq-5.13.2\bin\win64\wrapper.exe 启动

从http://localhost:8161/admin 登录

测试代码:

Sender:

public class Sender {

    private ConnectionFactory factory = null;
private Connection connection = null;
private Session session = null;
private Destination destination = null;
private MessageProducer producer = null; public Sender() { }; public void sendMessage() {
try {
factory = new ActiveMQConnectionFactory(ActiveMQConnection.DEFAULT_BROKER_URL);
connection = factory.createConnection();
connection.start();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
destination = session.createQueue("SAMPLEQUEUE");
producer = session.createProducer(destination);
TextMessage message = session.createTextMessage();
message.setText("Hello ...This is a sample message..sending from Sender");
producer.send(message);
System.out.println("Sent: " + message.getText()); } catch (JMSException e) {
e.printStackTrace();
}
} public static void main(String[] args) {
Sender sender = new Sender();
sender.sendMessage();
} }

producer

public class Receiver {
private ConnectionFactory factory = null;
private Connection connection = null;
private Session session = null;
private Destination destination = null;
private MessageConsumer consumer = null; public Receiver() {} public void receiveMessage() {
try {
factory = new ActiveMQConnectionFactory(ActiveMQConnection.DEFAULT_BROKER_URL);
connection = factory.createConnection();
connection.start();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
destination = session.createQueue("SAMPLEQUEUE");
consumer = session.createConsumer(destination);
//Message message = consumer.receive();//采用这种方式,消息的接收者会一直等待下去,直到有消息到达,或者超时
//注册一个监听器,当有消息到达的时候,回调它的onMessage()方法
consumer.setMessageListener(new MessageListener(){
@Override
public void onMessage(Message message) {
//消息消费者接收到这个消息之后,就可以得到它的内容:
if (message instanceof TextMessage) {
TextMessage text = (TextMessage) message;
try {
System.out.println("Message is : " + text.getText());
} catch (JMSException e) {
e.printStackTrace();
}
}
}
}); } catch (JMSException e) {
e.printStackTrace();
}
} public static void main(String[] args) {
Receiver receiver = new Receiver();
receiver.receiveMessage();
}
}

ActiveMQ StartUp的更多相关文章

  1. ActiveMQ从源代码构建

    众多开源项目.我们一般都是直接拿过来用之而后快. 只是我们也应该知道这些项目是怎样从源代码构建而来的. 既然代码是写出来的,就不能避免有BUG存在,话说没有完美的软件,也没有无漏洞的程序. 事实上从源 ...

  2. tomee 第一个 远程调用 Message-driven bean(MDB)

    MDB 整体结构 HelloMDB.java package cn.zno; import javax.jms.Connection; import javax.jms.ConnectionFacto ...

  3. ActiveMQ中的Destination高级特性(一)

    ---------------------------------------------------------------------------------------- Destination ...

  4. SignalR与ActiveMQ结合构建实时通信

    一.概述 本教程主要阐释了如何利用SignalR与消息队列的结合,实现不同客户端的交互 SignalR如何和消息队列交互(暂使用ActiveMQ消息队列) SignalR寄宿在web中和其他Signa ...

  5. Apache ActiveMQの版本更迭和Apache ActiveMQの故障转移

    本文描述apache activemq 版本更迭的原因以及Apache ActiveMQのThe Failover Transport new features in 5.2.0  1.对信息的传输/ ...

  6. apache activemq的重连

    1.activemq的重连机制 maxReconnectAttempts -1 | 0 From version 5.6 onwards: -1 is default and means retry ...

  7. ActiveMQ 安装异常

    解决方式: 1.确认计算机主机名名称没有下划线: 2.如果是win7,停止ICS(运行-->services.msc找到Internet Connection Sharing (ICS)服务,改 ...

  8. ActiveMQ点对点的消息发送案例

    公司最近会用MQ对某些业务进行处理,所以,这次我下载了apache-activemq-5.12.0-bin把玩下. 基于练习方便需要,使用Windows的版本. 参考的优秀文章: activemq的几 ...

  9. ActiveMQ(5.10.0) - Spring Support

    Maven Dependency: <dependencies> <dependency> <groupId>org.apache.activemq</gro ...

随机推荐

  1. 图解java面试

    图解Java面试题:基本语法 2017-02-07 14:34 出处:清屏网 人气:178 评论(0)   内容大纲.png &和&&的区别 &和&&的 ...

  2. USACO Section1.3 Wormholes 解题报告

    wormhole解题报告 —— icedream61 博客园(转载请注明出处)------------------------------------------------------------- ...

  3. webdriver--设置元素等待

    sleep():脚本执行到某一位置时“睡一会”,再继续执行:参数的单位是s:sleep方法由python的time模块提供,有两种引入和使用方式 import time time.sleep(5) f ...

  4. UIAutomator2、Appium、Robotium搭建环境与框架对比

    UIAutomator2.Appium.Robotium搭建环境与框架对比 一.框架介绍 Appium 特点 appium 是一个自动化测试开源工具,支持 iOS 平台和 Android 平台上的原生 ...

  5. 生成器 yield, next ,send

    重要的yield :相当于一个断层,我们再用next取拿出每一层重要的next :生成器查看装置,查看每一个断层重要的send :和next一样查看每一个段层,不过在查看第二个断层的时候,就可以对前面 ...

  6. 重复造轮子系列--内存池(C语言)

    这个代码是我上个公司工作项目的里面内存管理(基于伙伴算法)的一个简化又简化的版本. 因为没有内存边界检查: 因为没有内存使用统计: 因为没有考虑线程安全: 因为没有内存分配操作的具体文件位置信息: 因 ...

  7. (总结)Nginx使用的php-fpm的两种进程管理方式及优化

    PS:前段时间配置php-fpm的时候,无意中发现原来它还有两种进程管理方式.与Apache类似,它的进程数也是可以根据设置分为动态和静态的. php-fpm目前主要又两个分支,分别对应于php-5. ...

  8. Linux运维文档之nginx

    NGINX安装配置1.检查并且安装依赖组件检查安装nginx的依赖性,nginx的模块需要第三方库的支持,检查是否安装下列库:zlib.zlib-devel.openssl.openssl-devel ...

  9. nginx限速白名单配置

    在<nginx限制连接数ngx_http_limit_conn_module模块>和<nginx限制请求数ngx_http_limit_req_module模块>中会对所有的I ...

  10. 【CF Round 429 B. Godsend】

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...