Search code examples
gosuguidewire

How create a WorkQueue Guidewire?


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

Regards, Douglas Rezende


Solution

  • 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>