环境场景:
GlassFish 3.1.1
ActiveMQ5.5.0
1.直接安装或解压GlassFish3.1.1.
2.启动GlassFish.
3.在应用中安装 ActiveMq-rar-5.5.0.rar 资源适配包.
4.创建ConnectorPool.
5.创建受管理对像.
6.编写MDB.
@MessageDriven(mappedName = "jms/ActiveMqQueue", activationConfig = {
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destination",propertyValue = "ActiveMqQueue")})
public class TestMessageBean implements MessageListener{
public void onMessage(Message message) {
System.out.println("message is here");
}
}
请注意加粗部分.是配置Queue或Topic的名称
7.添加配置文件.
sun-ejb-jar.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-ejb-jar PUBLIC "-//Sun Microsystems, Inc.
//DTD Application Server 9.0 EJB 3.0//EN"
"http://www.sun.com/software/appserver/dtds/sun-ejb-jar_3_0-0.dtd">
<sun-ejb-jar>
<enterprise-beans>
<ejb>
<ejb-name>TestMessageBean</ejb-name>
<mdb-resource-adapter>
<resource-adapter-mid>activemq-rar-5.5.0</resource-adapter-mid>
</mdb-resource-adapter>
</ejb>
</enterprise-beans>
</sun-ejb-jar>
好像不要这个文件不行.监听启动不了.
注意:配好管理对像后日志会报.你所配的受管对像类型不正确.可以不理它.估计是GlassFish有问题.但不影响正常使用.
本文详细介绍了如何在GlassFish 3.1.1环境中部署并集成ActiveMQ,通过MDB(Message-Driven Bean)实现消息驱动功能,包括资源适配、配置文件设置以及MDB编写步骤。
188

被折叠的 条评论
为什么被折叠?



