如何配置无状态EJB(JBOSS)的最小实例?

时间:2017-10-08 08:33:03

标签: java java-ee jboss

我有一个无状态的ejb需要一些时间来初始化。为了避免这种成本,我希望总是将这个EJB的最小数量实例化。有没有像我可以在类似于MDB minInstances的bean基础上配置的minInstances?我怎么能做到这一点?

1 个答案:

答案 0 :(得分:0)

查看Wildfly 10.x中使用的StrictMaxPool implementation,无法设置最小尺寸。

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>

另一方面,release的{​​{1}}方法确实会释放所有已发布的bean:

StricMaxPool

这意味着一旦您创建了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(); } 个bean,池就不会缩小。因此,您可以在启动期间实现一些填充池的max-pool-size bean。