我们可以在 EJB 3.0 中使用 ejb-jar.xml 代替 MessageDrivenBean(MDB) 的注释吗?

发布于 2024-12-28 05:28:28 字数 169 浏览 1 评论 0原文

我已在 EJB 3.0 中使用 @ActivationConfigProperty 配置消息目标类型、名称等,但我想使用部署描述符 (ejb-jar.xml)与 EJB 2.0 中一样。

仅供参考:我正在使用 JBoss 6

谁能指导我?

I've configured the message destination type, name etc using @ActivationConfigProperty in EJB 3.0 but I wanted to configure the MDB using deployment descriptor (ejb-jar.xml) as in EJB 2.0.

FYI: I'm using JBoss 6

Can anyone guide me on this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

┾廆蒐ゝ 2025-01-04 05:28:28

谢谢你,但我已经用一种更简单的方式解决了这个问题。下面是代码

<ejb-jar id="ejb-jar_ID" version="3.1"
      xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                          http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd">

  <display-name>SampleTransactionMDB</display-name>
  <enterprise-beans>
    <message-driven>
      <display-name>SampleTransactionMDB</display-name>
      <ejb-name>SampleTransactionMDB</ejb-name>
      <ejb-class>com.example.SampleTransactionMDB</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>/queue/SampleTransactionQueue</activation-config-property-value>
        </activation-config-property> 
      </activation-config>
    </message-driven>  
  </enterprise-beans>
  <assembly-descriptor>
  </assembly-descriptor>
</ejb-jar>

Thanks man, but I've figured it out in a much simpler way. Below is the code

<ejb-jar id="ejb-jar_ID" version="3.1"
      xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                          http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd">

  <display-name>SampleTransactionMDB</display-name>
  <enterprise-beans>
    <message-driven>
      <display-name>SampleTransactionMDB</display-name>
      <ejb-name>SampleTransactionMDB</ejb-name>
      <ejb-class>com.example.SampleTransactionMDB</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>/queue/SampleTransactionQueue</activation-config-property-value>
        </activation-config-property> 
      </activation-config>
    </message-driven>  
  </enterprise-beans>
  <assembly-descriptor>
  </assembly-descriptor>
</ejb-jar>
若无相欠,怎会相见 2025-01-04 05:28:28

下面是配置MDB的xml内容,可以相应修改下面的代码。

<enterprise-beans>
    <message-driven>
        <ejb-name>SomeMessageBean</ejb-name>
        <ejb-class>
            com.bean.SomeMessageBean
        </ejb-class>
        <messaging-type>javax.jms.MessageListener</messaging-type>
        <transaction-type>Container</transaction-type>
        <message-destination-type>
            javax.jms.Queue
        </message-destination-type>
        <activation-config>
            <activation-property>
                <activation-config-property-name>destinationType
                </activation-config-property-name>
                <activation-config-property-value>javax.jms.Queue
                </activation-config-property-value>
            </activation-property>
            <activation-property>
                <activation-config-property-name>messageSelector
                </activation-config-property-name>
                <activation-config-property-value>MessageFormat = 'Version 3.4'
                </activation-config-property-value>
            </activation-property>
            <activation-property>
                <activation-config-property-name>acknowledgeMode
                </activation-config-property-name>
                <activation-config-property-value>Auto-acknowledge
                </activation-config-property-value>
            </activation-property>
        </activation-config>

        <resource-ref>
                    <resource-ref-name>jms/ConnectionFactory</resource-ref-name>
                    <resource-type>
                        javax.jms.ConnectionFactory
                    </resource-type>
                        <res-auth>Container</res-auth>
                        <mapped-name>ConnectionFactory</mapped-name>
                        <injection-target>
                            <injection-target-class>
                                com.bean.SomeMessageBean
                            </injection-target-class>
                            <injection-target-name>datasource</injection-target-name>
                        </injection-target>
                </resource-ref>
    </message-driven>
</enterprise-beans>

Below is the xml content for configuring MDB, can modify the below code accordingly.

<enterprise-beans>
    <message-driven>
        <ejb-name>SomeMessageBean</ejb-name>
        <ejb-class>
            com.bean.SomeMessageBean
        </ejb-class>
        <messaging-type>javax.jms.MessageListener</messaging-type>
        <transaction-type>Container</transaction-type>
        <message-destination-type>
            javax.jms.Queue
        </message-destination-type>
        <activation-config>
            <activation-property>
                <activation-config-property-name>destinationType
                </activation-config-property-name>
                <activation-config-property-value>javax.jms.Queue
                </activation-config-property-value>
            </activation-property>
            <activation-property>
                <activation-config-property-name>messageSelector
                </activation-config-property-name>
                <activation-config-property-value>MessageFormat = 'Version 3.4'
                </activation-config-property-value>
            </activation-property>
            <activation-property>
                <activation-config-property-name>acknowledgeMode
                </activation-config-property-name>
                <activation-config-property-value>Auto-acknowledge
                </activation-config-property-value>
            </activation-property>
        </activation-config>

        <resource-ref>
                    <resource-ref-name>jms/ConnectionFactory</resource-ref-name>
                    <resource-type>
                        javax.jms.ConnectionFactory
                    </resource-type>
                        <res-auth>Container</res-auth>
                        <mapped-name>ConnectionFactory</mapped-name>
                        <injection-target>
                            <injection-target-class>
                                com.bean.SomeMessageBean
                            </injection-target-class>
                            <injection-target-name>datasource</injection-target-name>
                        </injection-target>
                </resource-ref>
    </message-driven>
</enterprise-beans>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文