Skip to content

Commit

Permalink
* Move applications to projects/Applications and out of `projects/T…
Browse files Browse the repository at this point in the history
…est`.

* Tweak `PublisherConfirms` test application so that batches are 1/2 the number of outstanding confirms.
  • Loading branch information
lukebakken committed Oct 22, 2024
1 parent 4d0330b commit 45f69fe
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 17 deletions.
6 changes: 3 additions & 3 deletions Build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
<ProjectReference Include="projects/RabbitMQ.Client.OpenTelemetry/RabbitMQ.Client.OpenTelemetry.csproj" />
<ProjectReference Include="projects/toxiproxy-netcore/src/ToxiproxyNetCore/ToxiproxyNetCore.csproj" />
<ProjectReference Include="projects/Test/Common/Common.csproj" />
<ProjectReference Include="projects/Test/Applications/CreateChannel/CreateChannel.csproj" />
<ProjectReference Include="projects/Test/Applications/MassPublish/MassPublish.csproj" />
<ProjectReference Include="projects/Test/Applications/PublisherConfirms/PublisherConfirms.csproj" />
<ProjectReference Include="projects/Applications/CreateChannel/CreateChannel.csproj" />
<ProjectReference Include="projects/Applications/MassPublish/MassPublish.csproj" />
<ProjectReference Include="projects/Applications/PublisherConfirms/PublisherConfirms.csproj" />
<ProjectReference Include="projects/Test/Integration/Integration.csproj" />
<ProjectReference Include="projects/Test/SequentialIntegration/SequentialIntegration.csproj" />
<ProjectReference Include="projects/Test/Unit/Unit.csproj" />
Expand Down
9 changes: 4 additions & 5 deletions RabbitMQDotNetClient.sln
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Unit", "projects\Test\Unit\
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Benchmarks", "projects\Benchmarks\Benchmarks.csproj", "{38D72C9A-68E9-4653-B0CE-C7BA9FFD91D0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MassPublish", "projects\Test\Applications\MassPublish\MassPublish.csproj", "{0E3C4FBE-9976-40A3-9F57-DC0D9B7A39A6}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MassPublish", "projects\Applications\MassPublish\MassPublish.csproj", "{0E3C4FBE-9976-40A3-9F57-DC0D9B7A39A6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Applications", "Applications", "{D21B282C-49E6-4A30-887B-9626D94B8D69}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CreateChannel", "projects\Test\Applications\CreateChannel\CreateChannel.csproj", "{4A589408-F3A3-40E1-A6DF-F5E620F7CA31}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CreateChannel", "projects\Applications\CreateChannel\CreateChannel.csproj", "{4A589408-F3A3-40E1-A6DF-F5E620F7CA31}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RabbitMQ.Client.OAuth2", "projects\RabbitMQ.Client.OAuth2\RabbitMQ.Client.OAuth2.csproj", "{794C7B31-0E9A-44A4-B285-0F3CAF6209F1}"
EndProject
Expand All @@ -42,9 +42,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ToxiproxyNetCore", "project
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RabbitMQ.Client.OpenTelemetry", "projects\RabbitMQ.Client.OpenTelemetry\RabbitMQ.Client.OpenTelemetry.csproj", "{16BF2086-AC7D-4EC3-8660-CC16E663ACB1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GH-1647", "projects\Test\Applications\GH-1647\GH-1647.csproj", "{64ED07BF-4D77-47CD-AF4F-5B4525686FA1}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GH-1647", "projects\Applications\GH-1647\GH-1647.csproj", "{64ED07BF-4D77-47CD-AF4F-5B4525686FA1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PublisherConfirms", "projects\Test\Applications\PublisherConfirms\PublisherConfirms.csproj", "{13149F73-2CDB-4ECF-BF2C-403860045751}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PublisherConfirms", "projects\Applications\PublisherConfirms\PublisherConfirms.csproj", "{13149F73-2CDB-4ECF-BF2C-403860045751}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -115,7 +115,6 @@ Global
GlobalSection(NestedProjects) = preSolution
{B8FAC024-CC03-4067-9FFC-02846FB8AE48} = {EFD4BED5-13A5-4D9C-AADF-CAB7E1573704}
{0E3C4FBE-9976-40A3-9F57-DC0D9B7A39A6} = {D21B282C-49E6-4A30-887B-9626D94B8D69}
{D21B282C-49E6-4A30-887B-9626D94B8D69} = {EFD4BED5-13A5-4D9C-AADF-CAB7E1573704}
{4A589408-F3A3-40E1-A6DF-F5E620F7CA31} = {D21B282C-49E6-4A30-887B-9626D94B8D69}
{897D13F0-AF06-444A-9072-CF7E809A4A2C} = {EFD4BED5-13A5-4D9C-AADF-CAB7E1573704}
{B01347D8-C327-471B-A1FE-7B86F7684A27} = {EFD4BED5-13A5-4D9C-AADF-CAB7E1573704}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="../../../RabbitMQ.Client/RabbitMQ.Client.csproj" />
<ProjectReference Include="../../RabbitMQ.Client/RabbitMQ.Client.csproj" />
</ItemGroup>

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

<ItemGroup>
<ProjectReference Include="../../../RabbitMQ.Client\RabbitMQ.Client.csproj" />
<ProjectReference Include="../../RabbitMQ.Client\RabbitMQ.Client.csproj" />
</ItemGroup>

</Project>
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="../../../RabbitMQ.Client/RabbitMQ.Client.csproj" />
<ProjectReference Include="../../RabbitMQ.Client/RabbitMQ.Client.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
using System.Threading;
using System.Threading.Tasks;
using RabbitMQ.Client;
using RabbitMQ.Client.Impl;

const ushort MAX_OUTSTANDING_CONFIRMS = 256;

Expand All @@ -51,6 +50,11 @@
OutstandingPublisherConfirmationsRateLimiter = new ThrottlingRateLimiter(MAX_OUTSTANDING_CONFIRMS)
};

var props = new BasicProperties
{
Persistent = true
};

#pragma warning disable CS8321 // Local function is declared but never used

await PublishMessagesIndividuallyAsync();
Expand Down Expand Up @@ -82,7 +86,7 @@ async Task PublishMessagesIndividuallyAsync()
byte[] body = Encoding.UTF8.GetBytes(i.ToString());
try
{
await channel.BasicPublishAsync(exchange: string.Empty, routingKey: queueName, body: body);
await channel.BasicPublishAsync(exchange: string.Empty, routingKey: queueName, body: body, basicProperties: props, mandatory: true);
}
catch (Exception ex)
{
Expand All @@ -106,7 +110,7 @@ async Task PublishMessagesInBatchAsync()
QueueDeclareOk queueDeclareResult = await channel.QueueDeclareAsync();
string queueName = queueDeclareResult.QueueName;

int batchSize = MAX_OUTSTANDING_CONFIRMS;
int batchSize = MAX_OUTSTANDING_CONFIRMS / 2;
int outstandingMessageCount = 0;

var sw = new Stopwatch();
Expand All @@ -116,7 +120,7 @@ async Task PublishMessagesInBatchAsync()
for (int i = 0; i < MESSAGE_COUNT; i++)
{
byte[] body = Encoding.UTF8.GetBytes(i.ToString());
publishTasks.Add(channel.BasicPublishAsync(exchange: string.Empty, routingKey: queueName, body: body));
publishTasks.Add(channel.BasicPublishAsync(exchange: string.Empty, routingKey: queueName, body: body, mandatory: true, basicProperties: props));
outstandingMessageCount++;

if (outstandingMessageCount == batchSize)
Expand Down Expand Up @@ -279,7 +283,7 @@ async Task CleanOutstandingConfirms(ulong deliveryTag, bool multiple)
rk = Guid.NewGuid().ToString();
}
(ulong, ValueTask) data =
(nextPublishSeqNo, channel.BasicPublishAsync(exchange: string.Empty, routingKey: rk, body: body, mandatory: true));
(nextPublishSeqNo, channel.BasicPublishAsync(exchange: string.Empty, routingKey: rk, body: body, mandatory: true, basicProperties: props));
publishTasks.Add(data);
}

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

<ItemGroup>
<ProjectReference Include="../../../RabbitMQ.Client/RabbitMQ.Client.csproj" />
<ProjectReference Include="../../RabbitMQ.Client/RabbitMQ.Client.csproj" />
</ItemGroup>

</Project>

0 comments on commit 45f69fe

Please sign in to comment.