Skip to content

Commit 81b3141

Browse files
committed
working with rabbitmq and dot net core
1 parent db12982 commit 81b3141

38 files changed

+841
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
1. docker --version
2+
2. docker images
3+
3. docker run -d --hostname my-rabbit --name ecomm-rabbit -p 15672:15672 -p 5672:5672 rabbitmq:3-management
4+
4. docker logs -f 24a
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using RabbitMQ.Client;
2+
using System;
3+
using System.Text;
4+
5+
namespace RabbitMq.Consumer
6+
{
7+
class Program
8+
{
9+
static void Main(string[] args)
10+
{
11+
var factory = new ConnectionFactory
12+
{
13+
Uri = new Uri("amqp://guest:guest@localhost:5672")
14+
};
15+
using var connection = factory.CreateConnection();
16+
using var channel = connection.CreateModel();
17+
channel.QueueDeclare("demo-queue",
18+
durable: true,
19+
exclusive: false,
20+
autoDelete: false,
21+
arguments: null);
22+
23+
var consumer = new EventingBasicConsumer(channel);
24+
consumer.Received += (sender, e) => {
25+
var body = e.Body.ToArray();
26+
var message = Encoding.UTF8.GetString(body);
27+
console.writeLine("Message: " + message);
28+
};
29+
30+
channel.BasicConsume("demo-queue", true, consumer);
31+
Console.ReadLine();
32+
}
33+
}
34+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net5.0</TargetFramework>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<PackageReference Include="RabbitMQ.Client" Version="6.2.2" />
10+
</ItemGroup>
11+
12+
</Project>
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"format": 1,
3+
"restore": {
4+
"/home/julhas/Desktop/aspdotnetcore-development-strategies/cqrs-event-sourcing-rabbitmq-mongodb/RabbitMq.Consumer/RabbitMq.Consumer.csproj": {}
5+
},
6+
"projects": {
7+
"/home/julhas/Desktop/aspdotnetcore-development-strategies/cqrs-event-sourcing-rabbitmq-mongodb/RabbitMq.Consumer/RabbitMq.Consumer.csproj": {
8+
"version": "1.0.0",
9+
"restore": {
10+
"projectUniqueName": "/home/julhas/Desktop/aspdotnetcore-development-strategies/cqrs-event-sourcing-rabbitmq-mongodb/RabbitMq.Consumer/RabbitMq.Consumer.csproj",
11+
"projectName": "RabbitMq.Consumer",
12+
"projectPath": "/home/julhas/Desktop/aspdotnetcore-development-strategies/cqrs-event-sourcing-rabbitmq-mongodb/RabbitMq.Consumer/RabbitMq.Consumer.csproj",
13+
"packagesPath": "/home/julhas/.nuget/packages/",
14+
"outputPath": "/home/julhas/Desktop/aspdotnetcore-development-strategies/cqrs-event-sourcing-rabbitmq-mongodb/RabbitMq.Consumer/obj/",
15+
"projectStyle": "PackageReference",
16+
"configFilePaths": [
17+
"/home/julhas/.nuget/NuGet/NuGet.Config"
18+
],
19+
"originalTargetFrameworks": [
20+
"net5.0"
21+
],
22+
"sources": {
23+
"https://api.nuget.org/v3/index.json": {}
24+
},
25+
"frameworks": {
26+
"net5.0": {
27+
"targetAlias": "net5.0",
28+
"projectReferences": {}
29+
}
30+
},
31+
"warningProperties": {
32+
"warnAsError": [
33+
"NU1605"
34+
]
35+
}
36+
},
37+
"frameworks": {
38+
"net5.0": {
39+
"targetAlias": "net5.0",
40+
"dependencies": {
41+
"RabbitMQ.Client": {
42+
"target": "Package",
43+
"version": "[6.2.2, )"
44+
}
45+
},
46+
"imports": [
47+
"net461",
48+
"net462",
49+
"net47",
50+
"net471",
51+
"net472",
52+
"net48"
53+
],
54+
"assetTargetFallback": true,
55+
"warn": true,
56+
"frameworkReferences": {
57+
"Microsoft.NETCore.App": {
58+
"privateAssets": "all"
59+
}
60+
},
61+
"runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/5.0.401/RuntimeIdentifierGraph.json"
62+
}
63+
}
64+
}
65+
}
66+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8" standalone="no"?>
2+
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
4+
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
5+
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
6+
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
7+
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/home/julhas/.nuget/packages/</NuGetPackageRoot>
8+
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/home/julhas/.nuget/packages/</NuGetPackageFolders>
9+
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
10+
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.11.0</NuGetToolVersion>
11+
</PropertyGroup>
12+
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
13+
<SourceRoot Include="/home/julhas/.nuget/packages/" />
14+
</ItemGroup>
15+
<PropertyGroup>
16+
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
17+
</PropertyGroup>
18+
</Project>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" standalone="no"?>
2+
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
5+
</PropertyGroup>
6+
</Project>
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
{
2+
"version": 3,
3+
"targets": {
4+
"net5.0": {
5+
"RabbitMQ.Client/6.2.2": {
6+
"type": "package",
7+
"dependencies": {
8+
"System.Memory": "4.5.4",
9+
"System.Threading.Channels": "4.7.1"
10+
},
11+
"compile": {
12+
"lib/netstandard2.0/RabbitMQ.Client.dll": {}
13+
},
14+
"runtime": {
15+
"lib/netstandard2.0/RabbitMQ.Client.dll": {}
16+
}
17+
},
18+
"System.Memory/4.5.4": {
19+
"type": "package",
20+
"compile": {
21+
"ref/netcoreapp2.1/_._": {}
22+
},
23+
"runtime": {
24+
"lib/netcoreapp2.1/_._": {}
25+
}
26+
},
27+
"System.Threading.Channels/4.7.1": {
28+
"type": "package",
29+
"compile": {
30+
"lib/netcoreapp3.0/System.Threading.Channels.dll": {}
31+
},
32+
"runtime": {
33+
"lib/netcoreapp3.0/System.Threading.Channels.dll": {}
34+
}
35+
}
36+
}
37+
},
38+
"libraries": {
39+
"RabbitMQ.Client/6.2.2": {
40+
"sha512": "+tJSgE+rQXgLvOxWvOxdZ0+No1EMa86+puZuNlCb4cNryHw2PY2Xiw/y2dz/WWdeJQp74Y2UnNXPkuLiYpvn+A==",
41+
"type": "package",
42+
"path": "rabbitmq.client/6.2.2",
43+
"files": [
44+
".nupkg.metadata",
45+
".signature.p7s",
46+
"LICENSE",
47+
"icon.png",
48+
"lib/net461/RabbitMQ.Client.dll",
49+
"lib/net461/RabbitMQ.Client.pdb",
50+
"lib/net461/RabbitMQ.Client.xml",
51+
"lib/netstandard2.0/RabbitMQ.Client.dll",
52+
"lib/netstandard2.0/RabbitMQ.Client.pdb",
53+
"lib/netstandard2.0/RabbitMQ.Client.xml",
54+
"rabbitmq.client.6.2.2.nupkg.sha512",
55+
"rabbitmq.client.nuspec"
56+
]
57+
},
58+
"System.Memory/4.5.4": {
59+
"sha512": "1MbJTHS1lZ4bS4FmsJjnuGJOu88ZzTT2rLvrhW7Ygic+pC0NWA+3hgAen0HRdsocuQXCkUTdFn9yHJJhsijDXw==",
60+
"type": "package",
61+
"path": "system.memory/4.5.4",
62+
"files": [
63+
".nupkg.metadata",
64+
".signature.p7s",
65+
"LICENSE.TXT",
66+
"THIRD-PARTY-NOTICES.TXT",
67+
"lib/net461/System.Memory.dll",
68+
"lib/net461/System.Memory.xml",
69+
"lib/netcoreapp2.1/_._",
70+
"lib/netstandard1.1/System.Memory.dll",
71+
"lib/netstandard1.1/System.Memory.xml",
72+
"lib/netstandard2.0/System.Memory.dll",
73+
"lib/netstandard2.0/System.Memory.xml",
74+
"ref/netcoreapp2.1/_._",
75+
"system.memory.4.5.4.nupkg.sha512",
76+
"system.memory.nuspec",
77+
"useSharedDesignerContext.txt",
78+
"version.txt"
79+
]
80+
},
81+
"System.Threading.Channels/4.7.1": {
82+
"sha512": "6akRtHK/wab3246t4p5v3HQrtQk8LboOt5T4dtpNgsp3zvDeM4/Gx8V12t0h+c/W9/enUrilk8n6EQqdQorZAA==",
83+
"type": "package",
84+
"path": "system.threading.channels/4.7.1",
85+
"files": [
86+
".nupkg.metadata",
87+
".signature.p7s",
88+
"Icon.png",
89+
"LICENSE.TXT",
90+
"THIRD-PARTY-NOTICES.TXT",
91+
"lib/net461/System.Threading.Channels.dll",
92+
"lib/net461/System.Threading.Channels.xml",
93+
"lib/netcoreapp3.0/System.Threading.Channels.dll",
94+
"lib/netcoreapp3.0/System.Threading.Channels.xml",
95+
"lib/netstandard1.3/System.Threading.Channels.dll",
96+
"lib/netstandard1.3/System.Threading.Channels.xml",
97+
"lib/netstandard2.0/System.Threading.Channels.dll",
98+
"lib/netstandard2.0/System.Threading.Channels.xml",
99+
"system.threading.channels.4.7.1.nupkg.sha512",
100+
"system.threading.channels.nuspec",
101+
"useSharedDesignerContext.txt",
102+
"version.txt"
103+
]
104+
}
105+
},
106+
"projectFileDependencyGroups": {
107+
"net5.0": [
108+
"RabbitMQ.Client >= 6.2.2"
109+
]
110+
},
111+
"packageFolders": {
112+
"/home/julhas/.nuget/packages/": {}
113+
},
114+
"project": {
115+
"version": "1.0.0",
116+
"restore": {
117+
"projectUniqueName": "/home/julhas/Desktop/aspdotnetcore-development-strategies/cqrs-event-sourcing-rabbitmq-mongodb/RabbitMq.Consumer/RabbitMq.Consumer.csproj",
118+
"projectName": "RabbitMq.Consumer",
119+
"projectPath": "/home/julhas/Desktop/aspdotnetcore-development-strategies/cqrs-event-sourcing-rabbitmq-mongodb/RabbitMq.Consumer/RabbitMq.Consumer.csproj",
120+
"packagesPath": "/home/julhas/.nuget/packages/",
121+
"outputPath": "/home/julhas/Desktop/aspdotnetcore-development-strategies/cqrs-event-sourcing-rabbitmq-mongodb/RabbitMq.Consumer/obj/",
122+
"projectStyle": "PackageReference",
123+
"configFilePaths": [
124+
"/home/julhas/.nuget/NuGet/NuGet.Config"
125+
],
126+
"originalTargetFrameworks": [
127+
"net5.0"
128+
],
129+
"sources": {
130+
"https://api.nuget.org/v3/index.json": {}
131+
},
132+
"frameworks": {
133+
"net5.0": {
134+
"targetAlias": "net5.0",
135+
"projectReferences": {}
136+
}
137+
},
138+
"warningProperties": {
139+
"warnAsError": [
140+
"NU1605"
141+
]
142+
}
143+
},
144+
"frameworks": {
145+
"net5.0": {
146+
"targetAlias": "net5.0",
147+
"dependencies": {
148+
"RabbitMQ.Client": {
149+
"target": "Package",
150+
"version": "[6.2.2, )"
151+
}
152+
},
153+
"imports": [
154+
"net461",
155+
"net462",
156+
"net47",
157+
"net471",
158+
"net472",
159+
"net48"
160+
],
161+
"assetTargetFallback": true,
162+
"warn": true,
163+
"frameworkReferences": {
164+
"Microsoft.NETCore.App": {
165+
"privateAssets": "all"
166+
}
167+
},
168+
"runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/5.0.401/RuntimeIdentifierGraph.json"
169+
}
170+
}
171+
}
172+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": 2,
3+
"dgSpecHash": "WhSa1IxIj8ZW/FqdsmmwxpbM2yl1qbbGQtWnzRl2vThK4lneINkdTJ+vLdb8asVhQYb0vOh6dwFxWtXNmQy7ug==",
4+
"success": true,
5+
"projectFilePath": "/home/julhas/Desktop/aspdotnetcore-development-strategies/cqrs-event-sourcing-rabbitmq-mongodb/RabbitMq.Consumer/RabbitMq.Consumer.csproj",
6+
"expectedPackageFiles": [
7+
"/home/julhas/.nuget/packages/rabbitmq.client/6.2.2/rabbitmq.client.6.2.2.nupkg.sha512",
8+
"/home/julhas/.nuget/packages/system.memory/4.5.4/system.memory.4.5.4.nupkg.sha512",
9+
"/home/julhas/.nuget/packages/system.threading.channels/4.7.1/system.threading.channels.4.7.1.nupkg.sha512"
10+
],
11+
"logs": []
12+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using Newtonsoft.Json;
2+
using RabbitMQ.Client;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Text;
6+
using System.Threading;
7+
8+
namespace RabbitMq.Producer
9+
{
10+
static class Program
11+
{
12+
static void Main(string[] args)
13+
{
14+
var factory = new ConnectionFactory
15+
{
16+
Uri = new Uri("amqp://guest:guest@localhost:5672")
17+
};
18+
using var connection = factory.CreateConnection();
19+
using var channel = connection.CreateModel();
20+
channel.QueueDeclare("demo-queue",
21+
durable: true,
22+
exclusive: false,
23+
autoDelete: false,
24+
arguments: null);
25+
26+
var message = new { Name = "Producer", Message = "Hello!"};
27+
var body = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(message));
28+
29+
channel.BasicPublish("","demo-queue", null, body);
30+
}
31+
}
32+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net5.0</TargetFramework>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
10+
<PackageReference Include="RabbitMQ.Client" Version="6.2.2" />
11+
</ItemGroup>
12+
13+
</Project>

0 commit comments

Comments
 (0)