ActiveMQ的安装和基本使用
来源:互联网 发布:设备域名应该怎么设置 编辑:程序博客网 时间:2024/06/10 05:44
下载并安装ActiveMQ服务器端
1.列表内容从[http://activemq.apache.org/download.html下载最新的ActiveMQ
2.直接解压,然后拷贝到需要要安装的位置就OK
启动ActiveMQ
1.普通启动:进入到安装目录下面的bin目录下 ./activemq start
2.启动时指定日志文件:./activemq start > /temp/activemqlog
检查ActiveMQ服务是否启动
1.使用管理界面
打开管理界面http : //127.0.0.1 : 8161/admin/账号密码默认都是admin
2.查看控制台输出或者日志文件。
3.查看监听窗口 运行 netstat -nl | grep 61616 命令。ActiveMQ默认监听的是61616端口。
停止ActiveMQ
- 切换到 ActiveMQ/bin 运行 ./activemq stop
- ps -ef | grep activemq kill -9 进程号直接杀死。
简单用例
在使用ActiveMQ之前最好还是先了解JMS的基本原理和架构。http://blog.csdn.net/pengdandezhi/article/details/72779184
配置Maven依赖
<dependency><groupId>org.apache.activemq</groupId><artifactId>activemq-all</artifactId><version>5.9.0</version></dependency><dependency><groupId>org.apache.xbean</groupId><artifactId>xbean-spring</artifactId><version>3.16</version></dependency>
生产者发送消息
public class JmsSend{ public static void main(String[] args)throws Exception { ConnectionFactory connectionFactory = new ActiveMqConnectionFactory("tcp://192.168.1.129:61616"); Connection connection = connectionFactory.createConnection(); connection.start(); Session session = connection.createSession(Boolean.TRUE, Session.AUTO_ACKNOWLEDGE); Destination destination = session.createQueue("my-queue"); MessageProduce producer = session.createProducer(destination); TextMessage message = session.createTextMessage("message"); produecer.send(message); session.commit(); session.close(); connection.close(); }}
消费者接收消息
public class JmsSend{ public static void main(String[] args)throws Exception { ConnectionFactory connectionFactory = new ActiveMqConnectionFactory("tcp://192.168.1.129:61616"); Connection connection = connectionFactory.createConnection(); connection.start(); Session session = connection.createSession(Boolean.TRUE, Session.AUTO_ACKNOWLEDGE); Destination destination = session.createQueue("my-queue"); MessageConsumer consumer = session.createConsumer(destination); TextMessage message = consumer.receive(); System.out.println("消费者消费信息:" + messsage); session.commit(); session.close(); connection.close(); }}
阅读全文
0 0
- ActiveMQ的安装和基本使用
- ActiveMQ安装和基本使用
- ActiveMQ安装和基本使用
- ActiveMQ系列之二:ActiveMQ安装和基本使用
- ActiveMQ的基本使用
- ActiveMQ的基本使用
- ActiveMq的基本使用
- ActiveMQ安装和使用
- activemq安装和使用
- activemq的安装使用
- ActiveMQ单机安装和使用
- ActiveMQ单机安装和使用
- ActiveMQ安装和简单使用
- Java ActiveMQ 理解JMS 和 ActiveMQ基本使用
- Java ActiveMQ 理解JMS 和 ActiveMQ基本使用
- Java ActiveMQ 理解JMS 和 ActiveMQ基本使用
- Java ActiveMQ 理解JMS 和 ActiveMQ基本使用
- ActiveMQ的安装与使用
- TensorFlow实现图片分类
- PHP windows 调用com组件
- JS读取xml解析为ztree简单json类型
- [Docker]1.Windows下安装Docker
- Leetcode 501 Find Mode in Binary Search Tree
- ActiveMQ的安装和基本使用
- MySQL创建用户与授权方法
- hello node.js
- iOS-文本框字数限制
- MySQL开启远程连接权限
- Java虚拟机:class文件格式
- kotlin常用操作符
- 磁感应强度单位小计
- java.lang.IllegalArgumentException pointerIndex out of range