Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
03fad35
feat: inherit sources from the Users' code base
undrcrxwn Jun 28, 2023
0142d92
chore: add NuGet-specific project properties
undrcrxwn Jun 28, 2023
f9a9782
chore: add CrowdParlay logo as NuGet packages icon
undrcrxwn Jun 28, 2023
bec17ba
feat: add message consumption API
undrcrxwn Jun 29, 2023
ccc1932
tests: add RabbitMQ integration tests project
undrcrxwn Jun 29, 2023
f96e08f
feat: implement Microsoft DI integration for RabbitMQ communication
undrcrxwn Jul 2, 2023
7264e93
chore: update project version
undrcrxwn Jul 2, 2023
5f7cec6
feat(destination): improve exchange subscription API
undrcrxwn Jul 2, 2023
b302544
chore: update project version
undrcrxwn Jul 2, 2023
a84a8c2
chore: update project version
undrcrxwn Jul 2, 2023
85358e0
refactor: move UserEventsAwaitableConsumer to props folder
undrcrxwn Jul 2, 2023
2e2a699
feat: add generic test data injection attribute for setups
undrcrxwn Jul 2, 2023
9444ee1
chore(packages): reference Microsoft DI NuGets
undrcrxwn Jul 2, 2023
b544076
refactor: replace custom setup attribute with generic implementation
undrcrxwn Jul 2, 2023
f9648cd
tests: create unit tests project for Microsoft DI integration over Ra…
undrcrxwn Jul 2, 2023
c1adb56
fix(listener-initializer): replace scoped broker injection with scope…
undrcrxwn Jul 3, 2023
af9d2ab
chore: update project version
undrcrxwn Jul 3, 2023
b386abd
merge: RabbitMQ communication implementation
undrcrxwn Jul 8, 2023
2248778
feat: add AvatarUrl property to user events
undrcrxwn Jul 13, 2023
1432923
merge: update user event schemas
undrcrxwn Jul 14, 2023
44ad7fc
tests: remove redundant using directive
undrcrxwn Jul 14, 2023
82c171f
chore: update project version
undrcrxwn Jul 14, 2023
4966f5f
merge: update generic communication package
undrcrxwn Jul 14, 2023
755222e
feat: replace custom RabbitMQ wrapper with MassTransit
undrcrxwn Aug 5, 2023
c604c6f
chore: update project version
undrcrxwn Aug 5, 2023
823069a
chore: add README.md
undrcrxwn Aug 5, 2023
e5bc25a
merge: replace custom RabbitMQ wrapper with MassTransit
undrcrxwn Aug 5, 2023
2f29dc1
chore: upgrade to .NET 9
undrcrxwn Jun 24, 2025
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
9 changes: 9 additions & 0 deletions CrowdParlay.Communication.sln
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,20 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{6397F4A6-059A-4591-AB2F-9E0D28F8E619}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrowdParlay.Communication", "src\CrowdParlay.Communication\CrowdParlay.Communication.csproj", "{2A29A80A-0CB5-4914-B4D4-9595E667F874}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2A29A80A-0CB5-4914-B4D4-9595E667F874}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2A29A80A-0CB5-4914-B4D4-9595E667F874}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2A29A80A-0CB5-4914-B4D4-9595E667F874}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2A29A80A-0CB5-4914-B4D4-9595E667F874}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{2A29A80A-0CB5-4914-B4D4-9595E667F874} = {6397F4A6-059A-4591-AB2F-9E0D28F8E619}
EndGlobalSection
EndGlobal
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Crowd Parlay's .NET *communication* tools

### Technologies
`C#` `.NET 7` `MassTransit` `RabbitMQ`

### Responsibilities
- Platform-wide messaging types
- Common MassTransit configuration
- RabbitMQ topology maintenance

### Integration
Given `MassTransit.RabbitMQ` NuGet package and `IServiceCollection services` instance, `CrowdParlay.Communication` gets integrated as follows:

```csharp
using CrowdParlay.Communication;
using MassTransit;
```

```csharp
services.AddMassTransit(bus => bus.UsingRabbitMq((context, configurator) =>
{
var amqpServerUrl =
configuration["RABBITMQ_AMQP_SERVER_URL"]
?? throw new InvalidOperationException("Missing required configuration 'RABBITMQ_AMQP_SERVER_URL'.");

configurator.Host(amqpServerUrl);
configurator.ConfigureEndpoints(context);
configurator.ConfigureTopology(); // This extension method is defined in CrowdParlay.Communication
}));
```

Now, inject `IPublishEndpoint _broker` to publish messages like that:

```csharp
// UserCreatedEvent type is defined in CrowdParlay.Communication
var @event = new UserCreatedEvent(user.Id.ToString(), user.Username, user.DisplayName, user.AvatarUrl);
await _broker.Publish(@event, cancellationToken);
```
Binary file added docs/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions src/CrowdParlay.Communication/CrowdParlay.Communication.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Authors>CrowdParlay</Authors>
<Version>2.0.2</Version>
<Description>CrowdParlay's common .NET API for platform-wide communication.</Description>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<RepositoryUrl>https://gitlab.otter.su/crowdparlay/dotnet-communication</RepositoryUrl>
<PackageIcon>logo.png</PackageIcon>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\docs\logo.png">
<Pack>True</Pack>
<PackagePath></PackagePath>
<Link>logo.png</Link>
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Include="MassTransit.RabbitMQ" Version="8.5.0" />
</ItemGroup>

</Project>
18 changes: 18 additions & 0 deletions src/CrowdParlay.Communication/MassTransitExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using MassTransit;

namespace CrowdParlay.Communication;

public static class MassTransitExtensions
{
public static void ConfigureTopology(this IRabbitMqBusFactoryConfigurator configurator)
{
configurator.Message<UserCreatedEvent>(x => x.SetEntityName("user"));
configurator.Send<UserCreatedEvent>(x => x.UseRoutingKeyFormatter(_ => "user.created"));

configurator.Message<UserUpdatedEvent>(x => x.SetEntityName("user"));
configurator.Send<UserUpdatedEvent>(x => x.UseRoutingKeyFormatter(_ => "user.updated"));

configurator.Message<UserDeletedEvent>(x => x.SetEntityName("user"));
configurator.Send<UserDeletedEvent>(x => x.UseRoutingKeyFormatter(_ => "user.deleted"));
}
}
5 changes: 5 additions & 0 deletions src/CrowdParlay.Communication/Messages.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace CrowdParlay.Communication;

public record UserCreatedEvent(string UserId, string Username, string DisplayName, string? AvatarUrl);
public record UserUpdatedEvent(string UserId, string Username, string DisplayName, string? AvatarUrl);
public record UserDeletedEvent(string UserId);