0

I have a scenario where i need to call a Remote Action which makes a callout in a loop until i get some results from the external service. Reason to call it in a loop is that if for some input service returns null, i need to increase input and call service again. I am getting this warning email :

Caused the following Apex resource warnings: Number of callouts: 80 out of 100

Should i do something to handle this warning ?

1
  • 2
    I believe you should rethink your approach. If you are already making 80/100 callouts, if sometime you need to do 101+ callouts, your current approach won't work. Commented Jun 12, 2015 at 11:58

1 Answer 1

1

You could add limit handling, and check if the number of callouts already made is close to the limit. Once you are at the limit, you could log unsuccessful callouts, or show a nice message to the user. Alternatively, if no user should be involved, you could queue up a batch job to repeat these callouts until you get a valid response from the server.

Something like this after every call out:

if (Limits.getCallouts() == Limits.getLimitCallouts()) { // exit gracefully while adding a message to the page telling to try again, or queuing up a batch job with more call outs } 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.