I have two Azure Web Jobs running within my Azure web app:
- Job A - running continuously
- Job B - triggered
Job A's purpose is to trigger Job B based on two things:
- Job B has not been run in the past hour for a specified account number (passed into Job B as a param from Job A.
- Some other business logic determined from the database
#2 is easy. It's #1 that I have a question about. Is it possible for Job A query the web job queue to see if Job B has been executed?
Here is Job B (triggered):
public class Functions
{
public static void ProcessQueueMessage([QueueTrigger("triggeredqueue")] string message, TextWriter log)
{
var accountId = message;
//DO STUFF WITH accountId HERE...
}
}
And here is Job A (running continuously). I've added code in comments to show what I would like to do:
class Program
{
static void Main()
{
while (true)
{
var accounts = getAccounts();
foreach (var account in accounts) {
if (testOtherBusinessLogic(account)) {
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConnectionStringHelper.StorageConnectionString);
CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
CloudQueue queue = queueClient.GetQueueReference("triggeredqueue");
queue.CreateIfNotExists();
//THIS IS WHAT IT IS DOING NOW:
CloudQueueMessage message = new CloudQueueMessage(account.AccountId);
queue.AddMessage(message);
//THIS IS WHAT I WOULD LIKE IT TO DO:
/*
if (!queue.Any(x => x.RunDate > (DateTime.Now.AddMinutes(-60)) && x.Message == account.AccountId.ToString()) {
CloudQueueMessage message = new CloudQueueMessage(account.AccountId);
queue.AddMessage(message);
}
*/
}
}
System.Threading.Thread.Sleep(7000);
}
}
}