[英]How do you configure the min instances of Stateless EJB (JBOSS)?
I have a stateless ejb that takes some time to initialize. 我有一个无状态的ejb,需要一些时间来初始化。 To avoid this cost, I'd like there to always be a min number of this EJB instantiated. 为了避免这种花费,我希望实例化的EJB始终保持最小数量。 Is there something like minInstances that I can configure on a bean basis similar to MDB minInstances? 是否可以在bean的基础上配置类似于minInstances的东西,类似于MDB minInstances? How can I accomplish this? 我该怎么做?
Taking a look at the StrictMaxPool
implementation used in Wildfly 10.x, there is no option to set a minimum size. 看一下Wildfly 10.x中使用的StrictMaxPool
实现 ,没有设置最小大小的选项。
The XSD wildfly-ejb3_4_0.xsd does also not know something about a min size: XSD wildfly-ejb3_4_0.xsd也不了解最小大小:
<xs:complexType name="strict-max-poolType">
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="max-pool-size" type="xs:positiveInteger" default="20" use="optional"/>
<xs:attribute name="derive-size" type="xs:string" use="optional"/>
<xs:attribute name="instance-acquisition-timeout" type="xs:positiveInteger" default="5" use="optional"/>
<xs:attribute name="instance-acquisition-timeout-unit" type="timeout-unitType"
default="MINUTES" use="optional"/>
</xs:complexType>
On the other hand, the release
method of the StricMaxPool
does put all released beans back: 另一方面, StricMaxPool
的release
方法会将所有已发布的bean放回原处:
public void release(T obj) {
if (ROOT_LOGGER.isTraceEnabled()) {
ROOT_LOGGER.tracef("%s/%s Free instance: %s", pool.size(), maxSize, this);
}
pool.add(obj);
semaphore.release();
}
This means that once you have created max-pool-size
beans, the pool won't shrink. 这意味着一旦创建了max-pool-size
bean,池就不会缩小。 Hence you can implement some @Startup
bean that fills the pool during startup. 因此,您可以实现一些@Startup
bean,以在启动期间填充池。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.