安装配置ActiveMQ5.0
来源:互联网 发布:电脑城套路知乎 编辑:程序博客网 时间:2024/06/07 16:53
简介
ActiveMQ 是开源的JMS实现,Geronimo应用服务器就是使用的ActiveMQ提供JMS服务。ActiveMQ5.0相比以前版本提供了一些非常有用的新功能:
- AMQ Message Store (Faster Persistence!)
- Cursors (To handle very large number of stored messages)
- Blob Messages
- Command Agent
- Enterprise Integration Patterns via Camel Integration
- Logging a warning if you forget to start a Connection
- Message Transformation
- Mirrored Queues
- Flow Control
鉴于目前关于ActiveMQ5.0的文章比较少,故准备写一系列ActiveMQ的使用方面的文章。本篇先从安装开始。
安装
- 在http://activemq.apache.org/download.html下载5.0.0发行包,解压到需要安装ActiveMQ的文件夹,记为/path/to/activemq。
- unix环境activemq文件夹需要执行权限,执行如下命令 chmod -R 755 /path/to/activemq
启动
- window环境运行/path/to/activemq/bin/activemq.bat
- unix环境运行/path/to/activemq/bin/activemq
测试
ActiveMQ默认使用的TCP连接端口是61616, 通过查看该端口的信息可以测试ActiveMQ是否成功启动
- window环境运行 netstat -an|find "61616"
- unix环境运行netstat -an|grep 61616
监控
ActiveMQ5.0版本默认启动时,启动了内置的jetty服务器,提供一个demo应用和用于监控ActiveMQ的admin应用。
admin:http://127.0.0.1:8161/admin/
demo:http://127.0.0.1:8161/demo/
点击demo应用中的“ Market data publisher”,就会发一些测试的消息。转到admin页面的topics menu下面(queue和topic的区别见http://andyao.iteye.com/blog/153173),可以看到消息在增长。
配置
ActiveMQ5.0的配置文件在/path/to/activemq/conf目录下面。主要配置文件为activemq.xml,具体的配置将在后续文章中详细说明。
-------------------------------------------****************************************************************
持久化时不能对自定义类型的对象进行保存,看是不是你的messageConverter有问题?你的消息类型是POJO吗?
MessageConverter如下
- public class DefaultMessageConverter implements MessageConverter {
- /**
- * Logger for this class
- */
- private static final Log log = LogFactory.getLog(DefaultMessageConverter.class);
- public Message toMessage(Object obj, Session session) throws JMSException {
- if (log.isDebugEnabled()) {
- log.debug("toMessage(Object, Session) - start");
- }
- // check Type
- ActiveMQObjectMessage objMsg = (ActiveMQObjectMessage) session.createObjectMessage();
- HashMap<String, byte[]> map = new HashMap<String, byte[]>();
- try {
- // POJO must implements Seralizable
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(bos);
- oos.writeObject(obj);
- map.put("POJO", bos.toByteArray());
- objMsg.setObjectProperty("Map", map);
- } catch (IOException e) {
- log.error("toMessage(Object, Session)", e);
- }
- return objMsg;
- }
- public Object fromMessage(Message msg) throws JMSException {
- if (log.isDebugEnabled()) {
- log.debug("fromMessage(Message) - start");
- }
- if (msg instanceof ObjectMessage) {
- HashMap<String, byte[]> map = (HashMap<String, byte[]>) ((ObjectMessage) msg).getObjectProperty("Map");
- try {
- // POJO must implements Seralizable
- ByteArrayInputStream bis = new ByteArrayInputStream(map.get("POJO"));
- ObjectInputStream ois = new ObjectInputStream(bis);
- Object returnObject = ois.readObject();
- return returnObject;
- } catch (IOException e) {
- log.error("fromMessage(Message)", e);
- } catch (ClassNotFoundException e) {
- log.error("fromMessage(Message)", e);
- }
- return null;
- } else {
- throw new JMSException("Msg:[" + msg + "] is not Map");
- }
- }
- }
- 安装配置ActiveMQ5.0
- 安装配置ActiveMQ5.0
- ActiveMQ5.0实战一: 安装配置ActiveMQ5.0
- MQ系列1:安装配置ActiveMQ5.0
- ActiveMQ5.13 安装与配置
- linux下ActiveMQ5.13 安装与配置
- ActiveMQ5.4安全配置
- ActiveMQ5.5安全配置
- ActiveMQ5实战- 安装篇
- 安装Activemq5.13.2异常
- ActiveMQ5.13.5 安装
- 安装Activemq5.9.0异常
- Centos7安装activemq5.14.5
- 初手配置Tomcat6.0 + ActiveMq5.1 + Spring2.5
- ActiveMQ5.0实战
- ActiveMQ5.0实战
- RedHat系统安装ActiveMQ5.8.0
- linux配置activemq5使用mysql数据库
- JavaScript中的陷阱大集合
- 使用ActiveMQ 发送/接收消息(没用到框架)
- 桌面时钟的小例子
- 从UIImage转换到NSData类型
- pom.xml配置文件讲解
- 安装配置ActiveMQ5.0
- Drawable、Bitmap、Canvas和Paint的关系以及部分使用方法
- 抛掉重用的幻想,好使就行:用脚本生成脚本的例子
- 如何学好C++语言(转载,收藏)
- APPMODUL.cpp WinMain的问题?
- 通过Bundle传递Map类型数据
- jquery应用:
- android 设置为壁纸代码
- NSString+NSMutableString+NSValue+NSAraay用法汇总(很不错的哦)