1

I am sending email from my apex code using sendgrid API and after every call I am updating a flag in my object marking that email is sent.

I am doing DML after every callout because somehow any error occurs then duplicate emails should not went out.

Now, with my current approach, I made one future method which is making callout to sendgrid, so now there will be future method callout for every email sent. Here, many future request will be there.

My question is will be there be any issues if lot of future request are there in my org ?

1
  • The Dan Appleman book "Advanced Apex" 3rd Edition discusses a pattern on how to avoid these limits - see Chapter Asynchronous Processing. Well worth reading
    – cropredy
    Jan 14 '16 at 16:03
1

There is a limit on how many future callouts you can schedule, yes, as you can find out in the Execution Governors and Limits guide.

Namely:

The maximum number of asynchronous Apex method executions (batch Apex, future methods, Queueable Apex, and scheduled Apex) per a 24-hour period [is] 250,000 or the number of user licenses in your organization multiplied by 200, whichever is greater

So I wouldn't imagine this will be a problem if it is tied to a e-mail sending process, which has a much tighter limit.

Edit: In addition, one thing to consider (which hit me once) is if your future methods can be held up for a while on their callout to sendgrid, you cannot have more then 10 "running" at once or they will also be refused, so if you plan to send 20 e-mail and snap in 20 future methods with callouts at the same time, you might well hit a problem.

[The maximum] Number of synchronous concurrent requests for long-running requests that last longer than 5 seconds for each organization [is] 10

0

Yes, there is a limit to the number of future method calls invoked:

Maximum number of methods with the future annotation allowed per Apex invocation: 50

There is also an overall 24 hour rolling limit:

The maximum number of asynchronous Apex method executions (batch Apex, future methods, Queueable Apex, and scheduled Apex) per a 24-hour period: 250,000 or the number of user licenses in your organization multiplied by 200, whichever is greater

Source

1
  • 1
    snap! that must have been to the second as I didn't see the "new answer" flag appear as I wrote ;) Jan 14 '16 at 13:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.