Abstraction over common MQ channels with Rx.NET. Provides customizable messaging between clients and offers Observable endpoints for both topics and queues.
Example message implementation (ITopic
mechanic can be overwritten, it's just default behavior.)
public class TestMessageForTopic: ITopic
{
public Guid ExampleId { get; set; }
public string Something { get; set; }
public string TopicName => "v1.testtopic";
}
Sending message
await publisher.SendAsync(new TestMessage
{
ExampleId = id
});
subscriber.Messages<TestMessage>().Subscribe(message => Console.WriteLine(x.ExampleId));
Abstraction over Azure Service Bus.
Contains modern .NET Core version and legacy (4.5.2, 4.7.2, 4.8) version with full framework.
Configure AzureQueueMqSettings
, there are configuration methods which can be overwritten if required. Common reason for configuring factory methods are
- Multitenancy (with topics and subscription filters)
- Custom behavior how topic, subscription and queue names are built.
Requires NET core 2.x. and .NET Framework SDK 4.5.2, 4.7.2 and 4.8
Setting up test environment
- Create Application in Azure Active Directory
- Create configuration files
- Create a copy of
developer-settings.example.json
with namedeveloper-settings.json
- Replace
developer-settings.json
content with correct values
- Create a copy of
- Create testing environment
- Replace "ResourceGroupHere" with the actual name of the RG
- Run
Testing/Prepare-Environment.ps1 -EnvironmentName "ResourceGroupHere"
(see script for detailed documentation)
- Create client secrets
-
- Replace "ResourceGroupHere" with the actual name of the RG
- Run
Create-ClientSecrets.ps1 -EnvironmentName "ResourceGroupHere"
-
After running these steps, you should have a Service Bus in Azure and
client-secrets.json
-file for testing. Environment variables can also be used
for configurations. See AzureMqSettingsBase
for required configurations.
dotnet restore
dotnet test
NOTE: If build doesn't find correct SDK's even if those are installed,
please verify that ReferenceAssemblyRoot
is defined and set to correct location
In powershell, this can be done with
$env:ReferenceAssemblyRoot = 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework'
To be able to run tests
-
login to Azure with command line (Az login)
-
in root create developer-settings.json file for configuring test environment (Azure rg with service bus). Check developer-settings-example.json for reference (tag is vf subproject for devops if environment is created into pinja dev subscription)
-
run in Testing folder
Prepare-Testenvironment -SettingsFile developer-settings.json
-
In root run
Create-setcets.ps1 -SettingsFile developer-settings.json
This file creates secrets for test settings (dont commit)
-
run tests in core and legacy projects
note: You must have nuget credentials added to 'Protacon Nuget packages' repo to be able to do next steps
-
Make new release in Github with next version number and add description what is being changed
-
Create folder artifacts in same forlder where csproj to be published is located
-
In rootfolder run:
dotnet pack .\Protacon.RxMq.PLACEPROJECTFOLDERHERE\Protacon.RxMq.PLACEPROJECTHERE.csproj -c Release -o .\Protacon.RxMq.PLACEPROJECTFOLDERHERE\artifacts /p:Version=x.x.x
(version same as github release number)
-
Create ApiKey in Nuget Gallery (owner Protacon, select RxMq packages)
-
In artifacts folder publish to nuget.org:
dotnet nuget push Protacon.RxMq.PACKETPROJECT.x.x.x.nupkg --api-key YOURAPIKEY --source https://api.nuget.org/v3/index.json
Project uses Azure devops pipeline https://dev.azure.com/Protacon/Protacon.RxMq
Pipeline is authorized with service principal read from devops secret file
Nuget api key is devops pipeline variable $(nugetApiKey) create new in nuget org in your account if needed
It publishes nugets to https://www.nuget.org/packages?q=rxmq
Pipeline tag build triggers when new release with tag is made in github
Pipeline flow : build-create env for tests with secrets - run test -tear down env - if tag (release) publish nugets