Exemple #1
0
        /// <summary>
        ///   Sends a set of events to the associated Event Hub using a batched approach.  If the size of events exceed the
        ///   maximum size of a single batch, an exception will be triggered and the send will fail.
        /// </summary>
        ///
        /// <param name="events">The set of event data to send.</param>
        /// <param name="batchOptions">The set of options to consider when sending this batch.</param>
        /// <param name="cancellationToken">An optional <see cref="CancellationToken"/> instance to signal the request to cancel the operation.</param>
        ///
        /// <returns>A task to be resolved on when the operation has completed.</returns>
        ///
        /// <seealso cref="SendAsync(IEnumerable{EventData}, CancellationToken)" />
        ///
        public virtual Task SendAsync(IEnumerable <EventData> events,
                                      EventBatchingOptions batchOptions,
                                      CancellationToken cancellationToken = default)
        {
            Guard.ArgumentNotNull(nameof(events), events);

            batchOptions = batchOptions ?? DefaultBatchOptions;

            if ((!String.IsNullOrEmpty(PartitionId)) && (!String.IsNullOrEmpty(batchOptions.PartitionKey)))
            {
                throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, Resources.CannotSendWithPartitionIdAndPartitionKey, PartitionId));
            }

            return(InnerSender.SendAsync(events, batchOptions, cancellationToken));
        }
Exemple #2
0
 /// <summary>
 ///   Sends a set of events to the associated Event Hub using a batched approach.  If the size of events exceed the
 ///   maximum size of a single batch, an exception will be triggered and the send will fail.
 /// </summary>
 ///
 /// <param name="events">The set of event data to send.</param>
 /// <param name="batchOptions">The set of options to consider when sending this batch.</param>
 /// <param name="cancellationToken">An optional <see cref="CancellationToken"/> instance to signal the request for cancelling the operation.</param>
 ///
 /// <returns>A task to be resolved on when the operation has completed.</returns>
 ///
 /// <seealso cref="SendAsync(IEnumerable{EventData}, CancellationToken)" />
 ///
 public virtual Task SendAsync(IEnumerable <EventData> events,
                               EventBatchingOptions batchOptions,
                               CancellationToken cancellationToken = default) => throw new NotImplementedException();