计时器目前仅在我想要的一台服务器上触发,但是当我关闭该服务器时,它不会在另一台服务器上触发。
我有2个自由16.x服务器,它们都使用相同的数据源,并连接到derby db的相同网络版本。
server.xml:
<dataSource id="DefaultDataSource" jndiName="jdbc/DefaultDataSource" connectionSharing="MatchOriginalRequest" commitOrRollbackOnCleanup="rollback">
<jdbcDriver libraryRef="DerbyLib"/>
<properties.derby.client databaseName="/opt/db-derby-10.13.1.1-bin/databases/TEST_DB" createDatabase="false" serverName="localhost" portNumber="1088"/>
<containerAuthData user="user1" password="{xor}XXXX" />
</dataSource>
<library id="DerbyLib">
<fileset dir="/opt/db-derby-10.13.1.1-bin/lib"/>
</library>
每个服务器都通过EJB计时器部署了相同的EAR
EJB:
@Schedule(hour="*", minute="*", second="*", persistent=true)
public void timerExpired()
{
log.debug("%s collecting status...", System.getProperties().get("wlp.server.name"));
}
当他们每个人都使用自己的嵌入式derby版本时,计时器会每秒在每个服务器上触发一次。然后,我将其切换到derby的网络版本,其中两个服务器都使用相同的数据源,现在只有一个可以触发,这正是我想要的,但是我希望它在第一台服务器关闭时继续触发。
最佳答案
WebSphere Application Server Liberty当前缺乏EJB计时器的集群/故障转移功能,该功能允许计时器在不同的服务器上运行,您正在这里寻找它。传统的WebSphere Application Server具有此功能,但没有Liberty。
您应该使用IBM here打开一个增强请求,以表示将其添加到Liberty的要求,然后在此处链接到RFE,以便其他阅读此文档的人可以决定是否要为其投票以帮助证明对这种能力。