首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >JMS apache artemis - Wilfly10实现

JMS apache artemis - Wilfly10实现
EN

Stack Overflow用户
提问于 2017-05-16 18:21:53
回答 1查看 149关注 0票数 1

在Jboss 5.x中,JMS模型-队列(点对点)通常实现如下(MDB类和ejb-jar.xml)

MDB

代码语言:javascript
复制
package receiver;
import javax.jms.JMSException;
import javax.jms.MessageListener;
import javax.jms.TextMessage;
import javax.jms.Message;
public class WildFlyJmsQueueReceiveLocal  implements MessageListener {
public void onMessage(Message msg) {
 try {
     System.out.println("[WildFlyJmsQueueReceiveLocal][onMessage]There are three kinds of basic JMS connection-factory that depends on the type of connectors that is used.");          
   String msgText;
       if (msg instanceof TextMessage) {
          msgText = ((TextMessage)msg).getText();
       } else {
          msgText = msg.toString();
       }
       if (msgText.equalsIgnoreCase("quit")) {
         synchronized(this) {
             this.notifyAll(); // Notify main thread to quit
         }
       }           
  } catch (JMSException | InterruptedException jmse) {
      jmse.printStackTrace();
 }
}
}

ejb-jar.xml

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="3.0" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd">
<display-name>MDB</display-name>
<enterprise-beans>
<message-driven>
 <display-name>MDB1</display-name>
 <ejb-name>MDB1</ejb-name>
 <ejb-class>receiver.WildFlyJmsQueueReceiveLocal</ejb-class>
 <transaction-type>Container</transaction-type>
 <activation-config>
    <activation-config-property>
        <activation-config-property-name>destinationType</activation-config-property-name>
        <activation-config-property-value>javax.jms.Queue</activation-config-property-value>
    </activation-config-property>
    <activation-config-property>
        <activation-config-property-name>destination</activation-config-property-name>
        <activation-config-property-value>jms/queue/TestQ</activation-config-property-value>
    </activation-config-property>
    <activation-config-property>
    <activation-config-property-name>maxSession</activation-config-property-name>
   <activation-config-property-value>2</activation-config-property-value>
    </activation-config-property>
</activation-config>
</message-driven>
</enterprise-beans>
</ejb-jar>

现在我正在从jboss 5.x迁移到wildfly10。在wildfly 10中,已经使用'Apache ActiveMQ Artemis‘实现了JMS功能。因此,在wildfly 10中,首先我配置了队列'jms/ queue /TestQ‘,并尝试部署相同的代码(在jboss 5.x中使用),它运行成功。我以为我必须创建'ActiveMQConnectionFactory‘对象并做进一步的事情,但事实并非如此。我在Jboss 5.x中使用的JMS在wildfly10中工作得很好。

JMS发送方和接收方部署在同一个wildfly实例上。我是否正确地实现了JMS队列功能?在wildfly10中这样做是正确的吗?如果没有,请将我引向链接/文档。

我的Que是我在Jboss 5.x (用于JMS队列实现)中使用的Java代码,不需要任何更改就可以在Wildfly-10中工作?

EN

回答 1

Stack Overflow用户

发布于 2017-05-22 13:14:10

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43998780

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档