EJB学习手记

周末两天,看了两天的ejb知识。公司有个转发消息的程序,里面是根据ejb/jms+cdi/event做的,这些之前没接触过。

总而言之,从中学到了很多东西,从ejb到webservice。

jboss这个容器,貌似问题很多,新版本as7的怎么都跑不起来。还是用的as6,这个结构都是老的,用起来问题没那么多。

学习过程中,没什么大问题,主要是jboss的原因。大家要注意,as6的jms,配置消息目的地的时候,配置queue或者topic的方式,和网上大多数都是不同的。

上篇日志里面,配置queue或者topic的方式,对目前用的jboss6不适合。

常用的配置是:

<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: mail-service.xml 62350 2007-04-15 16:50:12Z dimitris@jboss.org $ -->
<server>


  <mbean code="org.jboss.mq.server.jmx.Queue"
         name="jboss.mq.destination:service=Queue,name=longgangbai">
    <attribute name="JNDIName">queue/longgangbai</attribute>
    <depends optional-attribute-name="DestinationManager" >jboss.mq:service=DestinationManager</depends>
  </mbean>

</server>

 

保存为xx-service.xml到发布的目录中,即可完成queue的发布。

在jboss6里面,不能这样用,要在发布目录的hornetq文件夹中,修改hornetq-jms.xml文件,在里面加入:

<topic name="topic1">
     <entry name="***"/>
 </topic>

entry name相当于jndi值,可以使用ctx.lookup("xxx")来找到这个topic。

同理,queue也一样。

原文地址:https://www.cnblogs.com/juepei/p/3856613.html