2008-01-05
ActiveMQ5.0实战一: 安装配置ActiveMQ5.0
关键字: activemq5.0 安装
/***作者:andyao,email:andyaoy@gmail.com*http://andyao.javaeye.com/blog/153171*/
简介
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.javaeye.com/blog/153173),可以看到消息在增长。
配置
ActiveMQ5.0的配置文件在/path/to/activemq/conf目录下面。主要配置文件为activemq.xml,具体的配置将在后续文章中详细说明。
评论
andyao
2008-01-11
springide2.0.2支持spring2.5吗
我现在用annotation,所以基本不用springide
我现在用annotation,所以基本不用springide
tewe2008
2008-01-10
我用你的配置和converter成功了:),但是springIDE还是有错误,不能代码提示。
springIDE2.02,spring2.5
配置:
我写的converter没有把pojo序列化到byte[]中就报错:
还有:http://activemq.apache.org/schema/core/activemq-core-5.0.0.xsd
这个和activemq5.0-core包里的spring-schemas中定义的并不一样!这样的话我的IDE就不能是实用本地的XSD吧?
springIDE2.02,spring2.5
配置:
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:jms="http://www.springframework.org/schema/jms" xmlns:amq="http://activemq.org/config/1.0" 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-2.5.xsd http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-2.5.xsd http://activemq.org/config/1.0 http://activemq.apache.org/schema/core/activemq-core-5.0.0.xsd">
我写的converter没有把pojo序列化到byte[]中就报错:
org.springframework.jms.UncategorizedJmsException: Uncategorized exception occured during JMS processing; nested exception is javax.jms.JMSException: Object is not a primitive: com.model.Item@767851f0
还有:http://activemq.apache.org/schema/core/activemq-core-5.0.0.xsd
这个和activemq5.0-core包里的spring-schemas中定义的并不一样!这样的话我的IDE就不能是实用本地的XSD吧?
andyao
2008-01-09
引用
你好啊,我现在正准备在项目中实用activemq,但是发现activemq5.0的XSD文件在springIDE中有错误,使的配置很麻烦!我用的是jvm内嵌式的,还有持久化时不能对自定义类型的对象进行保存,你碰到这些问题了吗?
你能讲清楚一点吗?
目前我们的project使用的就是ActiveMQ5.0, jvm embedder和单独的ActiveMQ5.0的服务器使用都没有问题。
目前使用的ActiveMQ5.0的XSD,没有错误
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:amq="http://activemq.org/config/1.0" 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.org/config/1.0 http://activemq.apache.org/schema/core/activemq-core-5.0.0.xsd">
引用
还有持久化时不能对自定义类型的对象进行保存
这个问题也没有碰到过,你看是不是你的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");
}
}
}
tewe2008
2008-01-09
你好啊,我现在正准备在项目中实用activemq,但是发现activemq5.0的XSD文件在springIDE中有错误,使的配置很麻烦!我用的是jvm内嵌式的,还有持久化时不能对自定义类型的对象进行保存,你碰到这些问题了吗?
javachs
2008-01-08
andyao 写道
引用
这个东东是不是类似IBM的Mq一样的东东
可以这样说,都是实现了JMS规范.
但是IBM MQ收费,当然功能更强大。
ActiveMQ是开源的。
我喜欢ActiveMQ是开源的,一切好东西都要有开源的,要不然外国大厂商和会IBM mq的人牛的不行。
andyao
2008-01-07
引用
这个东东是不是类似IBM的Mq一样的东东
可以这样说,都是实现了JMS规范.
但是IBM MQ收费,当然功能更强大。
ActiveMQ是开源的。
javachs
2008-01-07
这个东东是不是类似IBM的Mq一样的东东
xyh
2008-01-06
正想了解这个,尽快出下集吧,等不及了
发表评论
提醒: 该博客已发表在公共论坛,博客所有留言会成为论坛回贴,留言请注意遵守论坛发贴规则
- 浏览: 42885 次
- 性别:

- 来自: 北京

- 详细资料
搜索本博客
我的相册
Snap1
共 1 张
共 1 张
最新评论
-
使用Atomikos Transaction ...
引用Caused by: com.atomikos.icatch.SysExce ...
-- by bagui3 -
Struts2中使用Stream Res ...
Stream result type? 可有可无,把Respose的header ...
-- by ray_linn -
Struts2中使用Stream Res ...
我的程序,虽然结果出来了,但后台总是抛错:------------------- ...
-- by Acaleph -
使用Atomikos Transaction ...
Caused by: com.atomikos.icatch.SysExcept ...
-- by baoyaer -
Annotation风格的Spring M ...
刚用了spring MVC的annotation, 确实简单。应该说在简化问题上 ...
-- by slaser






评论排行榜