Guest User

Untitled

a guest
Nov 22nd, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. public static void testWithoutCallout(final Id leadId)
  2. {
  3. System.debug(DateTime.now().format('m:s') + ': Lock requested');
  4. final Lead lead = [Select id From Lead where id = :leadId FOR UPDATe];
  5. System.debug(DateTime.now().format('m:s') + ': Lock acquired');
  6. for(Integer i = 0; i < 30000000; i++) {}
  7. System.debug(DateTime.now().format('m:s') + ': Done');
  8. }
  9.  
  10. public static void testWithCallout(final Id leadId)
  11. {
  12. System.debug(DateTime.now().format('m:s') + ': Lock requested');
  13. final Lead lead = [Select id From Lead where id = :leadId FOR UPDATe];
  14. System.debug(DateTime.now().format('m:s') + ': Lock acquired');
  15.  
  16. final HttpRequest req = new HttpRequest();
  17. req.setEndPoint('https://www.google.de');
  18. req.setMethod('GET');
  19. final Http http = new Http();
  20. http.send(req);
  21.  
  22. for(Integer i = 0; i < 30000000; i++) {}
  23.  
  24. System.debug(DateTime.now().format('m:s') + ': Done');
  25.  
  26. }
  27.  
  28. Execution 1:
  29. 16:56: Lock requested
  30. 16:56: Lock acquired
  31. 17:02: Done
  32.  
  33. Execution 2:
  34. 16:59: Lock requested
  35. 17:59: Lock acquired
  36. 17:17: Done
  37.  
  38. Execution 1:
  39. 21:18: Lock requested
  40. 21:18: Lock acquired
  41. 21:34: Done
  42.  
  43.  
  44. Execution 2:
  45. 21:23: Lock requested
  46. 21:23: Lock acquired
  47. 21:38: Done
Add Comment
Please, Sign In to add comment