Esempio n. 1
0
        /// <summary>
        /// This method completes processing of the specified message, after the job function has been invoked.
        /// </summary>
        /// <remarks>
        /// The message is completed by the ServiceBus SDK based on how the <see cref="ServiceBusProcessorOptions.AutoCompleteMessages"/> option
        /// is configured. E.g. if <see cref="ServiceBusProcessorOptions.AutoCompleteMessages"/> is false, it is up to the job function to complete
        /// the message.
        /// </remarks>
        /// <param name="actions">The set of actions that can be performed on a <see cref="ServiceBusReceivedMessage"/>.</param>
        /// <param name="message">The <see cref="ServiceBusReceivedMessage"/> to process.</param>
        /// <param name="result">The <see cref="FunctionResult"/> from the job invocation.</param>
        /// <param name="cancellationToken">A cancellation token that will be cancelled when the processor is shutting down.</param>
        /// <returns>A <see cref="Task"/> that will complete the message processing.</returns>
        protected internal virtual Task CompleteProcessingMessageAsync(ServiceBusMessageActions actions, ServiceBusReceivedMessage message, FunctionResult result, CancellationToken cancellationToken)
        {
            if (message is null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            if (result == null)
            {
                throw new ArgumentNullException(nameof(result));
            }

            if (!result.Succeeded)
            {
                // if the invocation failed, we must propagate the
                // exception back to SB so it can handle message state
                // correctly
                throw result.Exception;
            }

            return(Task.CompletedTask);
        }
 public static ServiceBusTriggerInput CreateBatch(ServiceBusReceivedMessage[] messages, ServiceBusMessageActions actions, ServiceBusClient client)
 {
     return(new ServiceBusTriggerInput
     {
         Messages = messages,
         _isSingleDispatch = false,
         MessageActions = actions,
         Client = client
     });
 }
Esempio n. 3
0
 /// <summary>
 /// This method is called when there is a new message to process, before the job function is invoked.
 /// This allows any preprocessing to take place on the message before processing begins.
 /// </summary>
 /// <param name="actions">The set of actions that can be performed on a <see cref="ServiceBusReceivedMessage"/>.</param>
 /// <param name="message">The <see cref="ServiceBusReceivedMessage"/> to process.</param>
 /// <param name="cancellationToken">A cancellation token that will be cancelled when the processor is shutting down.</param>
 /// <returns>A <see cref="Task"/> that returns true if the message processing should continue, false otherwise.</returns>
 protected internal virtual Task <bool> BeginProcessingMessageAsync(ServiceBusMessageActions actions, ServiceBusReceivedMessage message, CancellationToken cancellationToken)
 {
     return(Task.FromResult <bool>(true));
 }
 public static ServiceBusTriggerInput CreateSingle(ServiceBusReceivedMessage message, ServiceBusMessageActions actions, ServiceBusClient client)
 {
     return(new ServiceBusTriggerInput
     {
         Messages = new ServiceBusReceivedMessage[]
         {
             message
         },
         _isSingleDispatch = true,
         MessageActions = actions,
         Client = client
     });
 }