Processing work items in a custom bulk insert work queue

You provide the programming logic for the writer thread of a bulk insert work queue by implementing the abstract processWorkItem method that your custom work queue class inherits from BulkInsertWorkQueueBase. The processWorkItem method takes a single argument, which is the work item type to use as the unit of work.

The following Gosu example code processes the units of work for a batch run, which are activities that no one has viewed in five days or more.

override function processWorkItem(workItem: StandardWorkItem) {
  // Extract an object reference to the unit of work: an Activity instance
  var activity = extractTarget(workItem) // Convert the ID of the target to an object reference
      
  if (activity.AssignedByUser.Contact.EmailAddress1 != null) {
    // Send an email to the user assigned to the activity
    EmailUtil.sendEmailWithBody(null, activity.AssignedUser.Contact,                     // To:
          null,                                                                          // From:
          "Activity not viewed for five days",                                           // Subject:
          "See activity" + activity.Subject + ", due on " + activity.TargetDate + ".")   // Body:
  }
}