Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plumb in BatchSize into ASB producer registry factory #1992

Merged
merged 2 commits into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,36 @@ public class AzureServiceBusProducerRegistryFactory : IAmAProducerRegistryFactor
{
private readonly IServiceBusClientProvider _clientProvider;
private readonly IEnumerable<AzureServiceBusPublication> _asbPublications;
private readonly int _bulkSendBatchSize;

/// <summary>
/// Creates a producer registry initialized with producers for ASB derived from the publications
/// </summary>
/// <param name="configuration">The configuration of the connection to AWS</param>
/// <param name="configuration">The configuration of the connection to ASB</param>
/// <param name="asbPublications">A set of publications - topics on the server - to configure</param>
public AzureServiceBusProducerRegistryFactory(
AzureServiceBusConfiguration configuration,
IEnumerable<AzureServiceBusPublication> asbPublications)
{
_clientProvider = new ServiceBusConnectionStringClientProvider(configuration.ConnectionString);
_asbPublications = asbPublications;
_bulkSendBatchSize = configuration.BulkSendBatchSize;
}

/// <summary>
/// Creates a producer registry initialized with producers for ASB derived from the publications
/// </summary>
/// <param name="clientProvider">The connection to AWS</param>
/// <param name="clientProvider">The connection to ASB</param>
/// <param name="asbPublications">A set of publications - topics on the server - to configure</param>
/// <param name="bulkSendBatchSize">The maximum size to chunk messages when dispatching to ASB</param>
public AzureServiceBusProducerRegistryFactory(
IServiceBusClientProvider clientProvider,
IEnumerable<AzureServiceBusPublication> asbPublications)
IEnumerable<AzureServiceBusPublication> asbPublications,
int bulkSendBatchSize = 10)
{
_clientProvider = clientProvider;
_asbPublications = asbPublications;
_bulkSendBatchSize = bulkSendBatchSize;
}


Expand All @@ -44,7 +49,7 @@ public IAmAProducerRegistry Create()
var producers = new Dictionary<string, IAmAMessageProducer>();
foreach (var publication in _asbPublications)
{
producers[publication.Topic] = AzureServiceBusMessageProducerFactory.Get(_clientProvider, publication);;
producers[publication.Topic] = AzureServiceBusMessageProducerFactory.Get(_clientProvider, publication, _bulkSendBatchSize);
}

return new ProducerRegistry(producers);
Expand Down
2 changes: 1 addition & 1 deletion src/Paramore.Brighter/IAmAProducerRegistryFactory.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region Licence
#region Licence
/* The MIT License (MIT)
Copyright © 2015 Toby Henderson <[email protected]>

Expand Down