Skip to content

Commit 0b32ef6

Browse files
Modernize executable tutorials
1. Adopt quorum queues for tutorials 1, 2, (partially) 6 for visibility and as a better defaults; other tutorials inherently can use exclusive queues 2. Improve some tutorial code, bump some clients 3. Add some instructions for background machine execution because that's not how the tutorials are generally written to be run (they are for interactive use by humans)
1 parent fef2ccd commit 0b32ef6

99 files changed

Lines changed: 246 additions & 162 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

dotnet/AGENTS.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Agent Notes for These .NET Tutorials
2+
3+
## `Console.ReadLine` in non-TTY environments
4+
5+
Consumer programs (Receive, Worker, ReceiveLogs, ReceiveLogsDirect, ReceiveLogsTopic,
6+
RPCServer) use `Console.ReadLine` to block until the user presses `[Enter]`.
7+
8+
When standard input is not connected to a TTY, `ReadLine()` returns `null` immediately and the process
9+
exits before receiving any deliveries.
10+
11+
Keep stdin open in automated or background contexts by piping from a blocking process:
12+
13+
```sh
14+
(while true; do sleep 20; done) | dotnet run --project Receive &
15+
(while true; do sleep 20; done) | dotnet run --project ReceiveLogs &
16+
```
17+
18+
The `Console.ReadLine()` and the "Press [enter] to
19+
exit." must never be deleted as a workaround: they exist for interactive use.

dotnet/EmitLog/EmitLog.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="RabbitMQ.Client" Version="7.0.0" />
11+
<PackageReference Include="RabbitMQ.Client" Version="7.2.1" />
1212
</ItemGroup>
1313

1414
</Project>

dotnet/EmitLogDirect/EmitLogDirect.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="RabbitMQ.Client" Version="7.0.0" />
11+
<PackageReference Include="RabbitMQ.Client" Version="7.2.1" />
1212
</ItemGroup>
1313

1414
</Project>

dotnet/EmitLogTopic/EmitLogTopic.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="RabbitMQ.Client" Version="7.0.0" />
11+
<PackageReference Include="RabbitMQ.Client" Version="7.2.1" />
1212
</ItemGroup>
1313

1414
</Project>

dotnet/NewTask/NewTask.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using var channel = await connection.CreateChannelAsync();
77

88
await channel.QueueDeclareAsync(queue: "task_queue", durable: true, exclusive: false,
9-
autoDelete: false, arguments: null);
9+
autoDelete: false, arguments: new Dictionary<string, object?> { { "x-queue-type", "quorum" } });
1010

1111
var message = GetMessage(args);
1212
var body = Encoding.UTF8.GetBytes(message);

dotnet/NewTask/NewTask.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="RabbitMQ.Client" Version="7.0.0" />
11+
<PackageReference Include="RabbitMQ.Client" Version="7.2.1" />
1212
</ItemGroup>
1313

1414
</Project>

dotnet/PublisherConfirms/PublisherConfirms.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="RabbitMQ.Client" Version="7.0.0" />
11+
<PackageReference Include="RabbitMQ.Client" Version="7.2.1" />
1212
</ItemGroup>
1313

1414
</Project>

dotnet/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Dotnet C# code for RabbitMQ tutorials
22

33
Here you can find the C# code examples for [RabbitMQ
4-
tutorials](https://www.rabbitmq.com/getstarted.html) using .NET 7.0.
4+
tutorials](https://www.rabbitmq.com/tutorials) using .NET 8 and RabbitMQ.Client 7.2.x.
55

66
You will also find a solution file for Visual Studio 2022.
77

dotnet/RPCClient/RPCClient.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="RabbitMQ.Client" Version="7.0.0" />
11+
<PackageReference Include="RabbitMQ.Client" Version="7.2.1" />
1212
</ItemGroup>
1313

1414
</Project>

dotnet/RPCServer/RPCServer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
using var connection = await factory.CreateConnectionAsync();
99
using var channel = await connection.CreateChannelAsync();
1010

11-
await channel.QueueDeclareAsync(queue: QUEUE_NAME, durable: false, exclusive: false,
12-
autoDelete: false, arguments: null);
11+
await channel.QueueDeclareAsync(queue: QUEUE_NAME, durable: true, exclusive: false,
12+
autoDelete: false, arguments: new Dictionary<string, object?> { { "x-queue-type", "quorum" } });
1313

1414
await channel.BasicQosAsync(prefetchSize: 0, prefetchCount: 1, global: false);
1515

0 commit comments

Comments
 (0)