我想为 MDB 配置maxsession所以在 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 上使用了相同的代码。