Hi,
I use the Engine API in an external application and I want to perfom a database operation in an activity (for example an insert operation).
The problem is that the client API return immediately when I execute the task (because “Each unit of work uses a non-blocking queued executor mechanism and is thus asynchronous” ) and then when I get pending tasks I don’t have the next activity to do becase the previous is still working.
The Event hanlder is not appropriate for my case because I have the client API in an external application.
It seems to be a strong limitation…any suggestions?
Add a wait loop…
Really, we’ve had to do this more than once, it’s the nature of the beast shall we say…
here is code code:
try {
TimeUnit.NANOSECONDS.sleep(100);
TimeUnit.MICROSECONDS.sleep(100);
TimeUnit.MILLISECONDS.sleep(100);
TimeUnit.SECONDS.sleep(100);
TimeUnit.MINUTES.sleep(100);
TimeUnit.HOURS.sleep(100);
TimeUnit.DAYS.sleep(100);
} catch (InterruptedException e) {
//Handle exception
}
See here for more information:
http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/TimeUnit.html
regards
Seán
PS: If this reply answers your question, please mark a resolved.
Thanks for your suggest Jean but I think it’s not a good solution.
You can’t predict the time of the execution of an activity, you can estimate a time but sometimes there could be events that increase this time, for example network congestion or database overload etc…
The best solution might be to set if an activity is synchronous or asynchronous but I think this choice is not provided, right ?
I think this is a strong limitation because an application is not composed of only asynchronous activities…
Appreciate the unable to time the event. I have the same problem…
Short of building your own semaphore mechanism the only other way would be to set up a “Message” But that means redesigning your batch program.
The way I’ve done it with some of our tasks is
int numberOfTries = 1;
int numberOfTriesLimit = 10;
boolean complete = false;
while (!complete){
TimeUnit.MICROSECONDS.sleep(1000); //wait a second
complete = checkIfComplete(“processID”); //returns false when not complete, true when complete
if numberOfTries.greaterThan(numberOfTriesLimit ){
exit while;
}
else{
numberOfTries++;
}
}
*checkIfComplete() *is your own function…
This way it looks for completion, and can wait forever if necessary, however for a timeout is always recommended (numberOfTriesLimit).
Not Synchronous but it works…
Otherwise add a IDEA to the list of things for Bonitasoft to so they can look at it and consider it for version x.y.z.
Otherwsie this is the easiest way for now.
regards
Seán
PS: If this reply answers your question, please mark a resolved.