I am working with an RPC call that may potentially take longer than the 60 second timeout and so I am attempting to use @AsyncFunction to get around this. I have followed the doc here for "Tracking Progress on the Gateway"
(https://docs.inductiveautomation.com:8443/display/SE/Providing+Progress+Information). I essentially duplicated the example code with very minor modifications. From what I can tell, doing this does get past the 60 second timeout, but the designer gets locked up and I am not seeing a progress dialog at all.
From the discussion here (@AsyncFunction - #2 by Colby.Clegg), I understand that the client locking up may be expected behavior. This is OK for my case, but I would like to get the progress dialog displaying at least so that the user knows that the data is being processed. In the thread linked above, the OP also was not getting a progress dialog to display and that particular issue was never resolved in the thread. I followed Colby's advice for setting the trace and here is what I see:
10:42:30.811 [AWT-EventQueue-0] DEBUG com.inductiveautomation.ignition.client.util.gui.progress.ClientProgressManager - Registering running task '92e51e14-77bd-4b2f-896e-cd0a6a1b6533'
10:42:30.812 [AWT-EventQueue-0] DEBUG com.inductiveautomation.ignition.client.util.gui.ProgressDialog2 - New state arrived, will wait 1 second to see if window should open.
10:42:30.938 [GatewayConnection-1] TRACE com.inductiveautomation.ignition.client.util.gui.progress.ClientProgressManager - Received state update: TaskUpdateState[finished=false, indeterminant=false, value=0, max=250, note=null, uid=92e51e14-77bd-4b2f-896e-cd0a6a1b6533]
10:42:30.938 [GatewayConnection-1] TRACE com.inductiveautomation.ignition.client.util.gui.progress.ClientProgressManager - Received state update: TaskUpdateState[finished=false, indeterminant=false, value=0, max=250, note=Executing test attempt: 0, uid=92e51e14-77bd-4b2f-896e-cd0a6a1b6533]
10:42:30.938 [GatewayConnection-1] TRACE com.inductiveautomation.ignition.client.util.gui.progress.ClientProgressManager - Received state update: TaskUpdateState[finished=false, indeterminant=false, value=1, max=250, note=Executing test attempt: 1, uid=92e51e14-77bd-4b2f-896e-cd0a6a1b6533]
10:42:30.938 [GatewayConnection-1] TRACE com.inductiveautomation.ignition.client.util.gui.progress.ClientProgressManager - Received state update: TaskUpdateState[finished=false, indeterminant=false, value=2, max=250, note=Executing test attempt: 2, uid=92e51e14-77bd-4b2f-896e-cd0a6a1b6533]
... redacted ...
10:42:41.123 [GatewayConnection-1] TRACE com.inductiveautomation.ignition.client.util.gui.progress.ClientProgressManager - Received state update: TaskUpdateState[finished=false, indeterminant=false, value=249, max=250, note=Executing test attempt: 249, uid=92e51e14-77bd-4b2f-896e-cd0a6a1b6533]
10:42:41.123 [GatewayConnection-1] TRACE com.inductiveautomation.ignition.client.util.gui.progress.ClientProgressManager - Received state update: TaskUpdateState[finished=true, indeterminant=false, value=0, max=0, note=null, uid=92e51e14-77bd-4b2f-896e-cd0a6a1b6533]
10:42:41.123 [AWT-EventQueue-0] DEBUG com.inductiveautomation.ignition.client.util.gui.progress.ClientProgressManager - Unregistering running task '92e51e14-77bd-4b2f-896e-cd0a6a1b6533'
10:42:41.124 [AWT-EventQueue-0] TRACE com.inductiveautomation.ignition.client.util.gui.ProgressDialog2 - Received display update while waiting to open: null
10:42:41.165 [AWT-EventQueue-0] DEBUG com.inductiveautomation.ignition.client.util.gui.ProgressDialog2 - Window will not be displayed- the task must have finished already.
It seems like the state updates are being received by the client, but the progress dialog never displays because it doesn't get a chance to until the method returns, at which point it determines that the task has already finished? I thought that the purpose of the @AsyncFunction annotation was to cause the method to be invoked in a separate thread so that the client would be able to check for status updates as the method runs.
Is there something I need to do to get the progress dialog to display? I have played around with both the SDK documentation as well as the thread linked above to no avail.
Here is the code for the @AsyncFunction which is in our gateway side RPC handler.
@Override
@AsyncFunction
public void processData() throws Exception {
//Gettheprogresslistenerforthisthread
TaskProgressListener progress = gatewayContext.getProgressManager().getProgressListenerForThread();
progress.setProgressMax(250);
for(Integer i=0; i<250; i++){
//Updateprogresstoshowcurrentstate.
progress.setProgress(i);
progress.setNote("Executing test attempt: " + i);
doWork();
//Ifthetaskhasbeencanceled,returnwhatwehavesofar
if (progress.isCanceled()) {
break;
}
}
}
Thank you,
Ryan