Archived

This forum has been archived. Please start a new discussion on GitHub.

Driving long running processes with Ice

Dear ZeroC,

I am currently programming a tool where I have an atomic function which takes multiple minutes for execution. This function is encapsulated within an Icebox service. Other steps of the workflow are encapsulated in other Icebox services.

For running the entire workflow, I have a program which consecutively calls the distinct services, collects the results and then decides about the next steps.

This principle works well, the only open issue is that I have this function which takes multiple minutes. For now, I am a synchronous call and ice_timeout(1000 * 60 * 30); to have 30 minutes for executing the function. This works for now, however, I wonder if this is the most robust implementation technique or whether it would be better to do the ami call and then wait for the result (as I cannot continue with the next steps of the workflow before continuing), like this (quasi-C# :) ):
bool criteriaMet = false; // switch to true when finished
ServicePrx prx = ...;
AMI_callme cb = new AMI_callme(ref criteriaMet);

prx.callme_async(cb);

while (!criteriaMet )
{
  System.Threading.Thread.Sleep(387);
  // check if we already wait longer than x minutes
}


which solution would you choose or do you see additional, more robust solutions for this scenario?

regs,

Stephan

Comments

  • matthew
    matthew NL, Canada
    I think either an AMI call, or a model where you make a twoway invocation and accept a callback with the results would be better. The advantage of the twoway invocation & callback is that you could potentially deal with application that drives the workflow termination and restarting a little easier since AMI state cannot be externalized.