1 Reply Latest reply on Apr 18, 2018 12:43 PM by jewellgm

    How to created the equivalent of a singleThreadedScheduledExecutor in wildfly

    jeffgaer

      I am on wildfly 9 jave 8

       

      I tried the following:

       

         <managed-scheduled-executor-service name="singleThreadedTimer" jndi-name="java:jboss/ee/concurrency/scheduler/singleThreadedTimer" context-service="default" hung-task-threshold="60000" core-threads="1" max-threads="1"  keepalive-time="3000"/>

       

      but it looks like maxThreads is not a valid attribute for managed-scheduled-executor-service

       

      17:14:24,282 ERROR [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0055: Caught exception during boot: org.jboss.as.controller.persistence.ConfigurationPersistenceException: WFLYCTL0085: Failed to parse configuration

          at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:131)

          at org.jboss.as.server.ServerService.boot(ServerService.java:350)

          at org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:271)

          at java.lang.Thread.run(Thread.java:745)

      Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[178,21]

      Message: WFLYCTL0197: Unexpected attribute 'max-threads' encountered

        • 1. Re: How to created the equivalent of a singleThreadedScheduledExecutor in wildfly
          jewellgm

          This is contained in the jboss-as-ee_3_0.xsd on how to define the managed-scheduled-executor-service:

           

              <xs:complexType name="managedScheduledExecutorServiceType">

                  <xs:annotation>

                      <xs:documentation>

                          A managed scheduled executor service (implementing javax.enterprise.concurrent.ManagedScheduledExecutorService).

                          If the "thread-factory" attribute is not defined a managed thread factory with no context service and normal thread priority will be created and used by the executor.

                      </xs:documentation>

                  </xs:annotation>

                  <xs:attribute name="name" type="nameType" use="required"/>

                  <xs:attribute name="jndi-name" type="jndiNameType" use="required"/>

                  <xs:attribute name="context-service" type="contextServiceNameType"/>

                  <xs:attribute name="thread-factory" type="threadFactoryType"/>

                  <xs:attribute name="hung-task-threshold" type="hungTaskThresholdType" default="0"/>

                  <xs:attribute name="long-running-tasks" type="longRunningTasksType" default="false"/>

                  <xs:attribute name="core-threads" type="coreThreadsType" use="required"/>

                  <xs:attribute name="keepalive-time" type="keepAliveTimeType" default="60000"/>

                  <xs:attribute name="reject-policy" type="rejectPolicyType" default="ABORT"/>

              </xs:complexType>

           

          where coreThreadsType is:

           

              <xs:simpleType name="coreThreadsType">

                  <xs:annotation>

                      <xs:documentation>

                          The number of threads to keep in the executor's pool, even if they are idle.

                          This type matches EE Concurrent 1.0 Final Release attribute named "Pool Info: Core Size", defined in sections 3.1.4.2 and 3.2.4.2

                      </xs:documentation>

                  </xs:annotation>

                  <xs:restriction base="xs:int">

                      <xs:minInclusive value="0"/>

                  </xs:restriction>

              </xs:simpleType>

           

          As you mentioned, maxThreads is not a valid attribute.  Based on the documentation, it looks like the coreThreads attribute is all you need.