WildFly中的集群数据库计时器

时间:2015-12-06 18:37:12

标签: java-ee timer ejb 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)

但我不认为这与根本问题有关。即使出现此错误,也会创建该表。

如何解决此错误?

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

其中BackgroundJobManager是一个单独的EJB,其中包含持久性计时器。计时器在文件系统中正确保留(默认),但无法持久保存到数据库。

我参加WildFly 9.0.2决赛。

1 个答案:

答案 0 :(得分:1)

目前,我的默认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>

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

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

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