+ Start a Discussion
Just Code ItJust Code It 

Call back Method for @future and Exception Design Pattern

Hi all,

Does anyone know if there's call back method mechanism that can be used with method declared with "@future"? Also, what's the standard exception handling design pattern for making Web Services call-outs (obviously, we need @future, which results in asynchronous calls).

 

Thank you for your ponter,

Best Answer chosen by Admin (Salesforce Developers) 
Shashikant SharmaShashikant Sharma

In future method :

 

Call back mechanism  : No there is no call back mechanism in future methods, these methods do get executed in future and there succes and failure can only be monitored in Administration setup->Monitoring->Apex jobs

 

In case of any system exception , Exception  mail notification will be send, 

 

Exception Handling: Now in most cases there is no need of exception handling in future method as no excetion will come to users screen in any case. But if you still want to do it you can use try catch block. In that case exception mail will not be send. 

 

 

 

 

All Answers

Shashikant SharmaShashikant Sharma

In future method :

 

Call back mechanism  : No there is no call back mechanism in future methods, these methods do get executed in future and there succes and failure can only be monitored in Administration setup->Monitoring->Apex jobs

 

In case of any system exception , Exception  mail notification will be send, 

 

Exception Handling: Now in most cases there is no need of exception handling in future method as no excetion will come to users screen in any case. But if you still want to do it you can use try catch block. In that case exception mail will not be send. 

 

 

 

 

This was selected as the best answer
Shabu Thomas.ax1924Shabu Thomas.ax1924

Hi,

 

The best strategy is to create an object called 'Application Log'. This log object should contain a lookup to user, time of exception, exception message, stack trace and one more- a lookup to case.

 

Then put try..catch block in future method. In case of exception create a log object. Create a case with a pre-configured (custom setting) user as the case owner. Set that case id in new application log record.

 

Then, a trigger on case can remove that record on closing that case.

 

This will given an efficient issue tracking feature also.

 

Thanks

Shabu