org.jbpm.executor.impl.wih

## Class AsyncWorkItemHandler

- java.lang.Object
- - org.jbpm.executor.impl.wih.AsyncWorkItemHandler

- All Implemented Interfaces:
    org.kie.api.runtime.process.WorkItemHandler, org.kie.internal.runtime.Cacheable

      public class AsyncWorkItemHandler
      extends Object
      implements org.kie.api.runtime.process.WorkItemHandler, org.kie.internal.runtime.Cacheable

  Asynchronous work item handler that utilizes power of `ExecutorService`. it expects following parameters to be present on work item for proper execution:
  - CommandClass - FQCN of the command to be executed - mandatory unless this handler is configured with default command class
  - Retries - number of retries for the command execution - optional
  - RetryDelay - Comma separated list of time expressions (5s, 2m, 4h) to be used in case of errors and retry needed.
  - Delay - optionally delay which job should be executed after given as time expression (5s, 2m, 4h) that will be calculated starting from current time
  - AutoComplete - allows to use "fire and forget" style so it will not wait for job completion and allow to move on (default false)
  - Priority - priority for the job execution - from 0 (the lowest) to 9 (the highest)
  During execution it will set contextual data that will be available inside the command:
  - businessKey - generated from process instance id and work item id in following format: [processInstanceId]:[workItemId]
  - workItem - actual work item instance that is being executed (including all parameters)
  - processInstanceId - id of the process instance that triggered this work item execution
  In case work item shall be aborted handler will attempt to cancel active requests based on business key (process instance id and work item id)

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AsyncWorkItemHandler(org.kie.api.executor.ExecutorService executorService)`
    `AsyncWorkItemHandler(org.kie.api.executor.ExecutorService executorService, String commandClass)`
    `AsyncWorkItemHandler(Object executorService, String commandClass)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `abortWorkItem(org.kie.api.runtime.process.WorkItem workItem, org.kie.api.runtime.process.WorkItemManager manager)`
    `protected String` | `buildBusinessKey(org.kie.api.runtime.process.WorkItem workItem)`
    `void` | `close()`
    `void` | `executeWorkItem(org.kie.api.runtime.process.WorkItem workItem, org.kie.api.runtime.process.WorkItemManager manager)`
    `protected long` | `getProcessInstanceId(org.kie.api.runtime.process.WorkItem workItem)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### AsyncWorkItemHandler

          public AsyncWorkItemHandler(org.kie.api.executor.ExecutorService executorService)

    - #### AsyncWorkItemHandler

          public AsyncWorkItemHandler(org.kie.api.executor.ExecutorService executorService,
                                      String commandClass)

    - #### AsyncWorkItemHandler

          public AsyncWorkItemHandler(Object executorService,
                                      String commandClass)

  - ### Method Detail

    - #### executeWorkItem

          public void executeWorkItem(org.kie.api.runtime.process.WorkItem workItem,
                                      org.kie.api.runtime.process.WorkItemManager manager)

      Specified by:
        `executeWorkItem` in interface `org.kie.api.runtime.process.WorkItemHandler`

    - #### abortWorkItem

          public void abortWorkItem(org.kie.api.runtime.process.WorkItem workItem,
                                    org.kie.api.runtime.process.WorkItemManager manager)

      Specified by:
        `abortWorkItem` in interface `org.kie.api.runtime.process.WorkItemHandler`

    - #### buildBusinessKey

          protected String buildBusinessKey(org.kie.api.runtime.process.WorkItem workItem)

    - #### getProcessInstanceId

          protected long getProcessInstanceId(org.kie.api.runtime.process.WorkItem workItem)

    - #### close

          public void close()

      Specified by:
        `close` in interface `org.kie.internal.runtime.Cacheable`

Copyright © 2001–2020 JBoss by Red Hat. All rights reserved.