在MDB中使用JNDI连接工厂

时间:2018-03-02 09:28:04

标签: java java-ee jboss ibm-mq

我们将MDB从IBM Web sphere迁移到Jboss 7.我们的消息代理是IBM MQ,我们正在使用资源适配器进行通信。我们在Jboss 7中定义了JNDI级别的jms连接工厂,我们希望在我们的EJB中使用它。

我们试图放入ejb-jar.xml,但它没有用,还有其他任何解决方案吗?

<?xml version="1.1" encoding="UTF-8"?>
<jboss:ejb-jar xmlns:jboss="http://www.jboss.com/xml/ns/javaee">
    <enterprise-beans>
        <message-driven>
            <ejb-name>MessageBean</ejb-name>
            <ejb-class>com.hi.helloMessageBean</ejb-class>
                <messaging-type>javax.jms.MessageListener</messaging-type>
    <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_1</activation-config-property-value>
                </activation-config-property>
                <activation-config-property>
                    <activation-config-property-name>connectionFactoryJndiName</activation-config-property-name>
                    <activation-config-property-value>jms/connec_fact_1</activation-config-property-value>
                </activation-config-property>



                <activation-config-property>
                    <activation-config-property-name>  
                        useJNDI  
                    </activation-config-property-name>
                    <activation-config-property-value>  
                        true  
                    </activation-config-property-value>
                </activation-config-property>



</activation-config>                


        </message-driven>
    </enterprise-beans>
    <assembly-descriptor>
        <d:delivery>
            <ejb-name>essageBean</ejb-name>
            <d:active>true</d:active> <!-- Change to false, to disable MDB delivery. -->
        </d:delivery>
        <container-transaction>
             <method>
                  <ejb-name>MessageBean</ejb-name>
                  <method-name>*</method-name>
             </method>
            <trans-attribute>RequiresNew</trans-attribute>
        </container-transaction>        
    </assembly-descriptor>
</jboss:ejb-jar>

2 个答案:

答案 0 :(得分:0)

由于提供的信息有限,很难知道如何回答您的问题。如果你得到的名字没有找到&#34;例外,所有JNDI名称应采用以下形式:

java:jboss/jms/queue_1

所有配置文件中的JNDI名称应与您在Web UI中的JNDI视图中看到的完全匹配。

答案 1 :(得分:0)

此外,最好将class MyTabbedPage extends StatefulWidget { const MyTabbedPage({Key key}) : super(key: key); @override _MyTabbedPageState createState() => new _MyTabbedPageState(); } class _MyTabbedPageState extends State<MyTabbedPage> with SingleTickerProviderStateMixin { final List<Tab> myTabs = <Tab>[ new Tab(text: 'LEFT'), new Tab(text: 'RIGHT'), ]; TabController _tabController; @override void initState() { super.initState(); _tabController = new TabController(vsync: this, length: myTabs.length); } @override void dispose() { _tabController.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return new Scaffold( appBar: new AppBar( bottom: new TabBar( controller: _tabController, tabs: myTabs, ), ), body: new TabBarView( controller: _tabController, children: myTabs.map((Tab tab) { return new Center(child: new Text(tab.text)); }).toList(), ), ); } } 设置为useJNDI,并将false名称设置为IBM MQ队列名称。只有少数情况需要在JBoss服务器配置文件的资源适配器部分中定义队列。