Andrea Azzola

Tips and Techniques for Lifestyle Design

Future count with Apex Code

Posted on [Permalink]

.A simple snippet for counting @future calls in a 24 hours timespan, may be useful for monitoring peaks and act accordingly.

Please note: supports up to 50000 future calls in a 24h timespan

public with sharing class AsyncApexJobUtils {
	public static integer futureCount() {
		integer c = [select count() from AsyncApexJob 
			where JobType='Future' 
			and CreatedDate >= :Datetime.now().addDays(-1) limit 50000];
		system.debug('#futureCount: ' + c);
		return c;
	}
}

 

Categories: