/// <summary> /// Initializes a new instance of the <see cref="AmqpEventBatch"/> class. /// </summary> /// /// <param name="messageConverter">The converter to use for translating <see cref="EventData" /> into the corresponding AMQP message.</param> /// <param name="options">The set of options to apply to the batch.</param> /// public AmqpEventBatch(AmqpMessageConverter messageConverter, BatchOptions options) { Guard.ArgumentNotNull(nameof(messageConverter), messageConverter); Guard.ArgumentNotNull(nameof(options), options); Guard.ArgumentNotNull(nameof(options.MaximumizeInBytes), options.MaximumizeInBytes); MessageConverter = messageConverter; Options = options; MaximumSizeInBytes = options.MaximumizeInBytes.Value; // Initialize the size by reserving space for the batch envelope. using var envelope = messageConverter.CreateBatchFromEvents(Enumerable.Empty <EventData>(), options.PartitionKey); _sizeBytes = envelope.SerializedMessageSize; }
/// <summary> /// Initializes a new instance of the <see cref="AmqpEventBatch"/> class. /// </summary> /// /// <param name="messageConverter">The converter to use for translating <see cref="EventData" /> into the corresponding AMQP message.</param> /// <param name="options">The set of options to apply to the batch.</param> /// public AmqpEventBatch(AmqpMessageConverter messageConverter, CreateBatchOptions options) { Argument.AssertNotNull(messageConverter, nameof(messageConverter)); Argument.AssertNotNull(options, nameof(options)); Argument.AssertNotNull(options.MaximumSizeInBytes, nameof(options.MaximumSizeInBytes)); MessageConverter = messageConverter; Options = options; MaximumSizeInBytes = options.MaximumSizeInBytes.Value; // Initialize the size by reserving space for the batch envelope. using AmqpMessage envelope = messageConverter.CreateBatchFromEvents(Enumerable.Empty <EventData>(), options.PartitionKey); ReservedSize = envelope.SerializedMessageSize; _sizeBytes = ReservedSize; }
/// <summary> /// Initializes a new instance of the <see cref="AmqpEventBatch"/> class. /// </summary> /// /// <param name="messageConverter">The converter to use for translating <see cref="EventData" /> into the corresponding AMQP message.</param> /// <param name="options">The set of options to apply to the batch.</param> /// <param name="activeFeatures">The flags specifying the set of special transport features have been opted-into.</param> /// public AmqpEventBatch(AmqpMessageConverter messageConverter, CreateBatchOptions options, TransportProducerFeatures activeFeatures) { Argument.AssertNotNull(messageConverter, nameof(messageConverter)); Argument.AssertNotNull(options, nameof(options)); Argument.AssertNotNull(options.MaximumSizeInBytes, nameof(options.MaximumSizeInBytes)); MessageConverter = messageConverter; Options = options; MaximumSizeInBytes = options.MaximumSizeInBytes.Value; ActiveFeatures = activeFeatures; // Initialize the size by reserving space for the batch envelope. At this point, the // set of batch events is empty, so the message returned will only represent the envelope. using AmqpMessage envelope = messageConverter.CreateBatchFromEvents(BatchEvents, options.PartitionKey); ReservedSize = envelope.SerializedMessageSize; _sizeBytes = ReservedSize; }