【问题标题】:Set maxsession for MDB through ejb-jar.xml in JBoss通过 JBoss 中的 ejb-jar.xml 为 MDB 设置 maxsession
【发布时间】:2017-04-25 01:51:13
【问题描述】:

我想为 MDB 配置 ma​​xsession 所以MDB类上有一个下面的注解

@ActivationConfigProperty(propertyName="maxSession",propertyValue="6")

片段

@MessageDriven
(activationConfig = 
    {
        @ActivationConfigProperty(propertyName = "acknowledgeMode",
                propertyValue = "Auto-acknowledge"),

        @ActivationConfigProperty(propertyName = "destinationType",
                propertyValue = "javax.jms.Queue"),

        @ActivationConfigProperty(propertyName = "destination",
                propertyValue = "queue/MyQueue"),

        @ActivationConfigProperty(propertyName = "reconnectAttempts",
                propertyValue = "-1"),

        @ActivationConfigProperty(propertyName = "setupAttempts",
                propertyValue = "-1"),                 

        @ActivationConfigProperty(propertyName="maxSession",propertyValue="6")
    },
    mappedName = "MyQueue"
)

我还在 ejb-jar.xml 中配置了 maxsession

<?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">
  <enterprise-beans>

    <message-driven>
      <ejb-name>MDBBean</ejb-name>
      <ejb-class>com.mybean.MDBBean</ejb-class>
    <messaging-type>javax.jms.MessageListener</messaging-type>

      <activation-config>

        <activation-config-property>
          <activation-config-property-name>maxSession</activation-config-property-name>
            <activation-config-property-value>20</activation-config-property-value>
        </activation-config-property>

      <activation-config-property>
            <activation-config-property-name>destination</activation-config-property-name>
            <activation-config-property-value>queue/MyQueue</activation-config-property-value>
        </activation-config-property>

        <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>
    </message-driven>

  </enterprise-beans>
</ejb-jar>

AFAIK 优先显示给 ejb-jar.xml 然后给注解。

但是当我通过 jmx-console 检查“ConsumerCount”时,它显示为 26。 这意味着它添加了两个值。 如果我从 cclass 文件中删除 @ActivationConfigProperty(propertyName="maxSession",propertyValue="6") ,它会显示 35(即默认 15,然后从 ejb-jar.xml 中添加 20)

我的要求是,它应该只从 ejb-jar.xml 中选择值。 注意:我不想从类中删除注释,因为在另一个 AS 上使用了相同的代码。

【问题讨论】:

    标签: jboss jms jboss6.x message-driven-bean jboss-mdb


    【解决方案1】:
    • AFAIK 优先显示给 ejb-jar.xml 然后给注解。

      这是预期的行为。文件描述符值优先于注解。

    • 但是当我通过 jmx-console 检查“ConsumerCount”时,它显示 26....

      我可以知道您使用的是哪个 JMS 代理和容器吗?我尝试使用带有 hornetQ 的 EAP 6.4.x。我通过 Jconsole 获得了正确的消费者数量:

    【讨论】:

    • JBoss AS 6 内部使用 HornetQ
    • @happy 我也尝试过使用 AS 6。它显示在 ejb-jar.xml 中定义的 ConsumerCount 值。这是我指的 MBean org.hornetq:module=JMS,type=Queue,name="$QUEUE_NAME"
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-09
    • 1970-01-01
    • 2015-10-12
    • 2014-01-28
    相关资源
    最近更新 更多