开发者

How to catch DeadlineExceedException in GAE/J?

How do you go about catching this exception in a servlet that takes longer than 30 seconds?

Thanks!开发者_StackOverflow社区


You can use a normal try-catch around your code and catch the DeadlineExceededException:

import com.google.apphosting.api.DeadlineExceededException

try {
  // your code
} catch (DeadlineExceededException e) {
  // do something here to handle the exception in a user-friendly way
}

Do remember that your time available after catching the DeadlineExceededException is limited. So you can't execute a lot of code inside the catch, because it will generate a HardDeadlineExceededError after a short period (generally < 1 sec).

So use it wisely and just return a message to user or do a quick cleanup to rollback anything if necessary.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜