Skip to content

Commit 3adef19

Browse files
committed
Add project files.
1 parent 21b185d commit 3adef19

File tree

5 files changed

+149
-0
lines changed

5 files changed

+149
-0
lines changed

Earth/Earth.csproj

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net6.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="RabbitMQ.Client" Version="6.2.3" />
12+
</ItemGroup>
13+
14+
</Project>

Earth/Program.cs

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using RabbitMQ.Client;
2+
using System.Text;
3+
4+
namespace Earth
5+
{
6+
internal class Program
7+
{
8+
static void Main(string[] args)
9+
{
10+
Console.WriteLine("Earth");
11+
12+
var factory = new ConnectionFactory()
13+
{
14+
HostName = "localhost",
15+
};
16+
17+
using var connection = factory.CreateConnection();
18+
using var channel = connection.CreateModel();
19+
20+
channel.QueueDeclare("inbox",
21+
false,
22+
false,
23+
false,
24+
null);
25+
26+
var message = " ";
27+
28+
while (message != string.Empty)
29+
{
30+
Console.WriteLine("type Message :");
31+
32+
message = Console.ReadLine();
33+
34+
var body = Encoding.UTF8.GetBytes(message);
35+
36+
channel.BasicPublish("",
37+
"inbox",
38+
null,
39+
body);
40+
41+
Console.WriteLine("sent from [Earth] : " + message);
42+
}
43+
44+
}
45+
}
46+
}

Moon/Moon.csproj

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net6.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="RabbitMQ.Client" Version="6.2.3" />
12+
</ItemGroup>
13+
14+
</Project>

Moon/Program.cs

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using RabbitMQ.Client;
2+
using RabbitMQ.Client.Events;
3+
using System.Text;
4+
5+
namespace Moon // Note: actual namespace depends on the project name.
6+
{
7+
internal class Program
8+
{
9+
static void Main(string[] args)
10+
{
11+
Console.WriteLine("Hello World! moon");
12+
13+
var factory = new ConnectionFactory()
14+
{
15+
HostName = "localhost",
16+
};
17+
18+
using var connection = factory.CreateConnection();
19+
using var channel = connection.CreateModel();
20+
21+
channel.QueueDeclare("inbox",
22+
false,
23+
false,
24+
false,
25+
null);
26+
27+
var consumer = new EventingBasicConsumer(channel);
28+
consumer.Received += Consumer_Received;
29+
30+
channel.BasicConsume("inbox",
31+
true,
32+
consumer);
33+
34+
Console.WriteLine(" Press [enter] to exit.");
35+
Console.ReadLine();
36+
}
37+
38+
private static void Consumer_Received(object? sender, BasicDeliverEventArgs e)
39+
{
40+
var message = Encoding.UTF8.GetString(e.Body.ToArray());
41+
Console.WriteLine($"Message received from earth : " + message);
42+
}
43+
}
44+
}

RabbitMQDemo.sln

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.32126.317
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Earth", "Earth\Earth.csproj", "{515DBB58-6655-476A-8AA6-D09EADD8D71C}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Moon", "Moon\Moon.csproj", "{3E3FCEA6-95AE-410B-8562-DF1507AD8D64}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Release|Any CPU = Release|Any CPU
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{515DBB58-6655-476A-8AA6-D09EADD8D71C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{515DBB58-6655-476A-8AA6-D09EADD8D71C}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{515DBB58-6655-476A-8AA6-D09EADD8D71C}.Release|Any CPU.ActiveCfg = Release|Any CPU
19+
{515DBB58-6655-476A-8AA6-D09EADD8D71C}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{3E3FCEA6-95AE-410B-8562-DF1507AD8D64}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{3E3FCEA6-95AE-410B-8562-DF1507AD8D64}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{3E3FCEA6-95AE-410B-8562-DF1507AD8D64}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{3E3FCEA6-95AE-410B-8562-DF1507AD8D64}.Release|Any CPU.Build.0 = Release|Any CPU
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
GlobalSection(ExtensibilityGlobals) = postSolution
29+
SolutionGuid = {91F34DED-6FD5-4D0D-8D6F-BFFD69F639DB}
30+
EndGlobalSection
31+
EndGlobal

0 commit comments

Comments
 (0)