问题
How to make maxSession value for an MDB user-configurable?
There is an MDB that listens for a message from a specific queue. It is defined as an annotation.
@ActivationConfigProperty(propertyName = "maxSession", propertyValue = "5")
.
In order to change the value of the maxSession, the code has to be compiled everytime.
Is there a way to make it user configurable so that there is no build required and without restarting jboss?
Kindly help.
回答1:
This is the way to externalize this setting from ear:
https://community.jboss.org/thread/178162
But restart is still required.
Update
Found a way to apply new maxSession with system property reference in 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>
Full JBoss restart is not required, only ear redeploy is needed in this case.
It works for all JBoss versions until JBoss AS 7.
Note that maxSession must be in sync with max pool size: https://community.jboss.org/message/549083#549083
回答2:
Note as well, that both the number of sessions and the instance pool size can be specified in an AOP configuration file:
<?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>
You then add the annotation:
@AspectDomain("IBMMQ Message Driven Bean")
to your MDB. This is can be used to externalize both the number of seesions and the instance pool size.
回答3:
According to this how many Message Driven Beans are created in Jboss? maxSession can't exceed the setting of StrictMaxPool. So when tweaking maxSession - this setting need to be changed as well!
来源:https://stackoverflow.com/questions/7331387/making-maxsession-property-configurable-for-a-specific-mdb-in-jboss-eap-5-1