Refresh variables for LockedExternalTask

Hello,

In rare cases, a worker will lock an external task before my custom execution listener has had a chance to set some variables. From what I understand, the variables returned when I call task.getVariables() are the variables which were in the task at lock time, not at the time of calling the getVariables() method.

What is the best way to handle this? The variables need to be set before the external task can be handled. I see two potential solutions:

  1. Call handleFailure() on the task, giving it a retry. This would then allow a worker to lock it again, hopefully with the proper variables this time.
  2. Somehow refresh the variables in the LockedExternalTask ? I do not currently know if there is a way to do this… I see that the constructor for LockedExternalTask calls execution.collectVariables(...), is there a good way to do this?

Thank you in advance for your help!

@ztaylor Please share your bpm process here?