Skip to content
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
3 changes: 2 additions & 1 deletion src/Hosting/Queue/src/BaseQueueHostedService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ private static RabbitMqClientOptions CreateOptions(BaseQueueHostedServiceOptions
ConnectionTimeout = options.ConnectionTimeout,
EnableSsl = options.EnableSsl,
IgnoreSslErrors = options.IgnoreSslErrors,
LoggerFactory = loggerFactory
LoggerFactory = loggerFactory,
ConsumerDispatchConcurrency = options.ConcurrentTaskCount
};

if (options.SslVersion != null)
Expand Down
5 changes: 5 additions & 0 deletions src/Hosting/Queue/src/BaseQueueHostedServiceOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,9 @@ public abstract class BaseQueueHostedServiceOptions
/// The serializer to use for deserializing messages from the Queue
/// </summary>
public IMessageSerializer? Serializer { get; set; }

/// <summary>
/// The number of tasks to run concurrently.
/// </summary>
public ushort ConcurrentTaskCount { get; set; } = 1;
}
4 changes: 0 additions & 4 deletions src/Hosting/Queue/src/QueueHostedServiceOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,4 @@ namespace ClickView.GoodStuff.Hosting.Queue;
/// </summary>
public abstract class QueueHostedServiceOptions : BaseQueueHostedServiceOptions
{
/// <summary>
/// The number of tasks to run concurrently.
/// </summary>
public ushort ConcurrentTaskCount { get; set; } = 1;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<ItemGroup>
<PackageReference Include="IdGen" Version="3.0.7" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.4" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.6" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Text.Json" Version="9.0.4" />
<PackageReference Include="System.Text.Json" Version="9.0.6" />
</ItemGroup>

<ItemGroup>
Expand Down
13 changes: 9 additions & 4 deletions src/Queues/RabbitMq/src/RabbitMqClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ public async Task EnqueueAsync<TData>(string exchange, TData data, EnqueueOption
var message = MessageWrapper<TData>.New(data);
var bytes = _options.Serializer.Serialize(message);

await using var channel = await GetChannelAsync(options.EnablePublisherConfirms, cancellationToken);
await using var channel = await GetChannelAsync(
options.EnablePublisherConfirms,
cancellationToken : cancellationToken);

var properties = new BasicProperties
{
Expand Down Expand Up @@ -79,7 +81,7 @@ public async Task<SubscriptionContext> SubscribeAsync<TData>(string queue,

// We don't want to dispose the channel here (unless an exception is thrown, see below).
// The returned SubscriptionContext is the object that should be disposed (which disposes the channel)
var channel = await GetChannelAsync(false, cancellationToken);
var channel = await GetChannelAsync(false, options.PrefetchCount, cancellationToken);

try
{
Expand Down Expand Up @@ -190,13 +192,16 @@ private async ValueTask<IConnection> ConnectSlowAsync(CancellationToken cancella
}
}

private async Task<IChannel> GetChannelAsync(bool enablePublisherConfirms, CancellationToken cancellationToken)
private async Task<IChannel> GetChannelAsync(bool enablePublisherConfirms,
ushort consumerDispatchConcurrency = 1,
CancellationToken cancellationToken = default)
{
var connection = await GetConnectionAsync(cancellationToken);

var options = new CreateChannelOptions(
publisherConfirmationsEnabled: enablePublisherConfirms,
publisherConfirmationTrackingEnabled: enablePublisherConfirms
publisherConfirmationTrackingEnabled: enablePublisherConfirms,
consumerDispatchConcurrency : consumerDispatchConcurrency
);

return await connection.CreateChannelAsync(options, cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<ItemGroup>
<PackageReference Include="Dapper" Version="2.1.66" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.4" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.6" />
<PackageReference Include="MySqlConnector" Version="2.4.0" />
<PackageReference Include="Polly" Version="8.6.0" />
</ItemGroup>
Expand Down