WildFly 中的集群数据库计时器

Clustered database timers in WildFly

standalone-full-ha.xml中应用以下配置。

<timer-service thread-pool-name="timer" default-data-store="clustered-store">
    <data-stores>
        <database-data-store name="clustered-store"
                             datasource-jndi-name="java:jboss/datasources/projectXADatasource"
                             database="mysql"
                             partition="timer"/>
    </data-stores>
</timer-service>

位于 java:jboss/datasources/projectXADatasource 的 XA 数据源已经工作正常。

应用程序未部署。部署过程失败并出现以下错误。

ERROR [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 2) WFLYCTL0013: Operation ("deploy") failed
- address: ([("deployment" => "WildFly.ear")])
- failure description: {"WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.deployment.subunit.\"WildFly.ear\".\"WildFly-ejb.jar\".component.BackgroundJobManager.ejb3.timerService is missing [jboss.thread.executor.ejb3.timer]"]}

将相同的配置应用于非集群环境 (standalone-full.xml) 也失败并出现相同的错误。


我唯一改变的是来自

的DDL语句
create-table.mysql=CREATE TABLE JBOSS_EJB_TIMER (ID VARCHAR(255) PRIMARY KEY NOT NULL...

create-table.mysql=CREATE TABLE JBOSS_EJB_TIMER (ID VARCHAR(191) PRIMARY KEY NOT NULL...

${Home}/modules/system/layers/base/org/jboss/as/ejb3/main/timers/timer-sql.properties

下可用

因为 MySQL 配置为使用 utf8mb4 字符集,VARCHAR(255) 超出了主键(767 字节)的范围。

JDBC 驱动程序在进行此更改后仍会出现以下错误。

21:07:07,750 ERROR [org.jboss.as.ejb3] (MSC service thread 1-7) WFLYEJB0163: Cannot create table for timer persistence: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Specified key was too long; max key length is 767 bytes
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
    at com.mysql.jdbc.Util.getInstance(Util.java:387)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:941)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3870)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3806)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2470)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2617)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2546)
    at com.mysql.jdbc.StatementImpl.executeUpdateInternal(StatementImpl.java:1541)
    at com.mysql.jdbc.StatementImpl.executeLargeUpdate(StatementImpl.java:2605)
    at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1469)
    at com.mysql.jdbc.jdbc2.optional.StatementWrapper.executeUpdate(StatementWrapper.java:749)
    at org.jboss.jca.adapters.jdbc.WrappedStatement.executeUpdate(WrappedStatement.java:414)
    at org.jboss.as.ejb3.timerservice.persistence.database.DatabaseTimerPersistence.checkDatabase(DatabaseTimerPersistence.java:286)
    at org.jboss.as.ejb3.timerservice.persistence.database.DatabaseTimerPersistence.start(DatabaseTimerPersistence.java:160)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

但我认为这与根本问题无关。 table 即使在出现此错误后也会创建。


如何解决这个错误?

component.BackgroundJobManager.ejb3.timerService is missing [jboss.thread.executor.ejb3.timer]

其中 BackgroundJobManager 是一个具有持久计时器的单例 EJB。计时器在文件系统中正确持久化(默认),但未能持久化到数据库中。

我正在使用 WildFly 9.0.2 final。

目前,我将使用默认的 thread-pool,如下所示。

<timer-service thread-pool-name="default" default-data-store="clustered-store">
    <data-stores>
        <database-data-store name="clustered-store" datasource-jndi-name="java:jboss/datasources/projectXADatasource" database="mysql" partition="timer"/>
    </data-stores>
</timer-service>

standalone-full-ha.xml中默认的thread-pool定义如下

<thread-pools>
    <thread-pool name="default">
        <max-threads count="10"/>
        <keepalive-time time="100" unit="milliseconds"/>
    </thread-pool>
</thread-pools>

欢迎提出任何其他想法或建议。