Exemplo n.º 1
0
        /// <summary>
        /// Use this to increase visibility timeout of a job which might take longer to process
        /// </summary>
        /// <param name="jobDetails">
        /// Job Details
        /// </param>
        /// <param name="newTimeout">
        /// What should be the new timeout
        /// </param>
        /// <returns>
        /// Async Task Wrapper
        /// </returns>
        public async Task IncreaseVisibilityTimeout(ScheduledJobDetails jobDetails, TimeSpan newTimeout)
        {
            if (jobDetails == null)
            {
                throw new SchedulerException("JobDetails cannot be null");
            }

            Log.Info("Updating timeout of job {0} to {1} ", jobDetails.JobId, newTimeout.ToString());
            AzureScheduledJobDetails azureJobDetails = jobDetails as AzureScheduledJobDetails;
            CloudQueueMessage        message         = AzureScheduledJobDetails.ToCloudQueueMessage(azureJobDetails);
            await azureQueueProvider.IncreaseTimeout(message, newTimeout).ConfigureAwait(false);

            Log.Info("Successfully updated timeout of job {0} ", jobDetails.JobId);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Update the job payload to the new payload specified
        /// </summary>
        /// <param name="jobDetails">
        /// Details of the job to be updated
        /// </param>
        /// <returns>
        /// Task wrapper for async operation
        /// </returns>
        /// <remarks>
        /// This update is done in place, hence queue order is not changed.
        /// Please be aware that this call only updates the payload.
        /// Imp : NOT THREADSAFE. So multiple calls can arrive out of order
        /// to make payload be off sync. Be careful if you have to use it.
        /// </remarks>
        public async Task UpdateJobPayload(ScheduledJobDetails jobDetails)
        {
            if (jobDetails == null)
            {
                throw new SchedulerException("JobDetails cannot be null");
            }

            string errorMessage;

            if (!jobDetails.ValidateUpdate(out errorMessage))
            {
                throw new SchedulerException(errorMessage);
            }

            Log.Info("Incoming request to update payload of a job \r\n" +
                     "details: {0}", jobDetails);

            TableResult result = await azureTableProvider.RetrieveAsync(
                ScheduledJobEntity.GetPartitionKey(jobDetails.JobType),
                ScheduledJobEntity.GetRowKey(jobDetails.JobId)).ConfigureAwait(false);

            ScheduledJobEntity entity = (ScheduledJobEntity)result.Result;

            if (entity != null)
            {
                entity.Payload = JsonConvert.SerializeObject(jobDetails.Payload);
                await azureTableProvider.UpdateAsync(entity).ConfigureAwait(false);

                AzureScheduledJobDetails azureJobDetails = jobDetails as AzureScheduledJobDetails;
                CloudQueueMessage        message         = AzureScheduledJobDetails.ToCloudQueueMessage(azureJobDetails);
                // azureJobDetails.QueueMessage = null;
                message.SetMessageContent(JsonConvert.SerializeObject(jobDetails));
                await azureQueueProvider.UpdateAsync(message).ConfigureAwait(false);
            }

            Log.Info("Successfully updated payload of job {0} ", jobDetails.JobId);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Delete job from the queue
 /// </summary>
 /// <param name="jobDetails">
 /// Job Details
 /// </param>
 /// <returns>
 /// Task wrapper for async operations
 /// </returns>
 private async Task DeleteJobFromQueueAsync(ScheduledJobDetails jobDetails)
 {
     await azureQueueProvider.DeleteAsync(
         AzureScheduledJobDetails.ToCloudQueueMessage((AzureScheduledJobDetails)jobDetails)).ConfigureAwait(false);
 }