1

I need create a workqueue in guidewire, but not find guidewire documentation about this. Someone can help me please?

Regards, Douglas Rezende

1 Answers1

9

You need several things:

  1. Make a new Typecode in BatchProcessType typekey (For example MyNewCode). Additionally you need add categories: Schedulable, UIRunnable or APIRunnable according to your need.
  2. Make a new class that extends WorkQueueBase like this
class MyWorkQueue extends WorkQueueBase<Message, StandardWorkItem> {
  private final static var _batchProcessType = BatchProcessType.TC_MYNEWCODE
  construct() {
    super(_batchProcessType, StandardWorkItem, Message)
  }

  override function findTargets(): Iterator<Message> {
    return Query.make(Message).select().iterator()
  }

  override function processWorkItem(p0: StandardWorkItem) {
    var bean = extractTarget(p0)
    // My process
  }
}

  1. Register the new class in work-queue.xml. You can search in the documentation additional parameters like retryLimit, retryInterval, server, env, maxpollinterval, etc.
<work-queue workQueueClass="example.MyWorkQueue" progressinterval="600000">
        <worker instances="1" batchsize="5" />
</work-queue>
  1. Register the new BatchProcessType in scheduler-config.xml (Optional). For it works correctly the typecode needs the Schedulable category (first step)
<ProcessSchedule process="MyNewCode">
    <CronSchedule minutes="*/10" />
</ProcessSchedule>
β.εηοιτ.βε
  • 33,893
  • 13
  • 69
  • 83
Carlos Duque
  • 482
  • 3
  • 7
  • I can create my entity and not use StandardWorkItem? – Douglas Rezende Nov 13 '18 at 01:34
  • I don't be sure, why? – Carlos Duque Nov 14 '18 at 02:08
  • I was able to create my custom workitem, very simple, thanks a lot – Douglas Rezende Nov 15 '18 at 17:50
  • yeah u can create your own work item, the only thing is you need to implement entity "WorkItem" in your custom entity and it should be keyable also (because data needs to be permanently deleted from the table once its used). Aslo there is one more function "createWorkItem(bean : StandardWorkItem, bundle:Bundle)" . you can use this to map the data from worker to workitem. – Aravind Pillai Apr 11 '19 at 08:25
  • Is there a "completed" method I can override so it executes only once at the end of all "processWorkItem" iterations? – krystine.e Jun 17 '19 at 17:31
  • No, but you can create a plugin with interface IBatchCompletedNotification, there you can validate the Process that was completed and do an action. ${MODULE_HOME}/doc/wwhelp/wwhimpl/js/html/wwhelp.htm#href=System Administration Guide/batch.11.08.html – Carlos Duque Jun 17 '19 at 19:14