如何使 MDB 用户可配置的 maxSession 值?
有一个 MDB 用于侦听来自特定队列的消息。它被定义为注解。
@ActivationConfigProperty(propertyName = "maxSession", propertyValue = "5")
.
为了改变 maxSession 的值,每次都必须编译代码。
有没有办法让它用户可配置,这样就不需要构建并且不需要重新启动 jboss?
请帮忙。
如何使 MDB 用户可配置的 maxSession 值?
有一个 MDB 用于侦听来自特定队列的消息。它被定义为注解。
@ActivationConfigProperty(propertyName = "maxSession", propertyValue = "5")
.
为了改变 maxSession 的值,每次都必须编译代码。
有没有办法让它用户可配置,这样就不需要构建并且不需要重新启动 jboss?
请帮忙。
这是从耳朵外部化此设置的方法:
https://community.jboss.org/thread/178162
但是仍然需要重新启动。
更新
找到了一种使用系统属性引用应用新 maxSession的方法ejb-jar.xml
:
<activation-config-property>
<activation-config-property-name>maxSession</activation-config-property-name>
<activation-config-property-value>${my.mdb.maxSession:30}</activation-config-property-value>
</activation-config-property>
不需要完全重新启动 JBoss,在这种情况下只需要重新部署 ear。
它适用于JBoss AS 7之前的所有 JBoss 版本。
请注意,maxSession 必须与最大池大小同步: https ://community.jboss.org/message/549083#549083
还要注意,会话数和实例池大小都可以在 AOP 配置文件中指定:
<?xml version="1.0" encoding="UTF-8"?>
<aop xmlns="urn:jboss:aop-beans:1.0">
<domain name="IBMMQ Message Driven Bean" extends="Message Driven Bean" inheritBindings="true">
<annotation expr="class(*)">
@org.jboss.ejb3.annotation.Pool (value="StrictMaxPool", maxSize=10, timeout=10000)
</annotation>
<annotation expr="!class(@org.jboss.ejb3.annotation.DefaultActivationSpecs)">
@org.jboss.ejb3.annotation.DefaultActivationSpecs (value={@javax.ejb.ActivationConfigProperty(propertyName = "channel", propertyValue = "SSL.CLIENTS"), @javax.ejb.ActivationConfigProperty(propertyName = "queueManager", propertyValue = "SSLQM"), @javax.ejb.ActivationConfigProperty(propertyName = "hostName", propertyValue = "10.0.0.124"), @javax.ejb.ActivationConfigProperty(propertyName = "port", propertyValue = "1415"), @javax.ejb.ActivationConfigProperty(propertyName = "transportType", propertyValue = "CLIENT"), @javax.ejb.ActivationConfigProperty(propertyName = "sslCipherSuite", propertyValue = "SSL_RSA_WITH_3DES_EDE_CBC_SHA")})
</annotation>
</domain>
</aop>
然后添加注释:
@AspectDomain("IBMMQ Message Driven Bean")
到您的 MDB。这可用于外部化查看次数和实例池大小。
据此,在 Jboss 中创建了多少个消息驱动 Bean?maxSession 不能超过 StrictMaxPool 的设置。因此,在调整 maxSession 时 - 此设置也需要更改!