Skip to content

Commit

Permalink
Prepare rtm and remove use of simple json (#445)
Browse files Browse the repository at this point in the history
* Prepare for RTM

* Remove simple json

* Guards

* Tweaks

---------

Co-authored-by: Brandon Ording <bording@gmail.com>
  • Loading branch information
andreasohlund and bording authored Feb 19, 2024
1 parent e7757ce commit 5676f89
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 2,189 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ jobs:
uses: actions/setup-dotnet@v4.0.0
with:
dotnet-version: 8.0.x
dotnet-quality: 'preview'
- name: Build
run: dotnet build src --configuration Release
- name: Upload packages
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ jobs:
uses: actions/setup-dotnet@v4.0.0
with:
dotnet-version: 8.0.x
dotnet-quality: 'preview'
- name: Build
run: dotnet build src --configuration Release
- name: Sign NuGet packages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="NServiceBus.AcceptanceTesting" Version="9.0.0-alpha.2" />
<PackageReference Include="NServiceBus.AcceptanceTesting" Version="9.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>$(SolutionDir)NServiceBusTests.snk</AssemblyOriginatorKeyFile>
<AssemblyOriginatorKeyFile>..\NServiceBusTests.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\NServiceBus.Heartbeat\NServiceBus.Heartbeat.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="NServiceBus" Version="9.0.0-alpha.2" />
<PackageReference Include="GitHubActionsTestLogger" Version="2.3.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="NServiceBus" Version="9.0.0" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="PublicApiGenerator" Version="11.1.0" />
Expand Down
20 changes: 14 additions & 6 deletions src/NServiceBus.Heartbeat/HeartbeatConfigurationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,30 @@ public static class HeartbeatConfigurationExtensions
/// <summary>
/// Sets the ServiceControl queue address.
/// </summary>
/// <param name="config">The enddpoint congfiguration to modify.</param>
/// <param name="config">The endpoint configuration to modify.</param>
/// <param name="serviceControlQueue">ServiceControl queue address.</param>
/// <param name="frequency">The frequency to send heartbeats.</param>
/// <param name="timeToLive">The maximum time to live for the heartbeat.</param>
public static void SendHeartbeatTo(this EndpointConfiguration config, string serviceControlQueue, TimeSpan? frequency = null, TimeSpan? timeToLive = null)
{
config.EnableFeature<HeartbeatsFeature>();
ArgumentNullException.ThrowIfNull(config);
ArgumentException.ThrowIfNullOrWhiteSpace(serviceControlQueue);

config.GetSettings().Set("NServiceBus.Heartbeat.Queue", serviceControlQueue);
if (timeToLive.HasValue)
{
config.GetSettings().Set("NServiceBus.Heartbeat.Ttl", timeToLive.Value);
}

if (frequency.HasValue)
{
ArgumentOutOfRangeException.ThrowIfLessThan(frequency.Value, TimeSpan.Zero);
config.GetSettings().Set("NServiceBus.Heartbeat.Interval", frequency.Value);
}

if (timeToLive.HasValue)
{
ArgumentOutOfRangeException.ThrowIfLessThan(timeToLive.Value, TimeSpan.Zero);
config.GetSettings().Set("NServiceBus.Heartbeat.Ttl", timeToLive.Value);
}

config.EnableFeature<HeartbeatsFeature>();
}
}
}
45 changes: 0 additions & 45 deletions src/NServiceBus.Heartbeat/MessageSerializationStrategy.cs

This file was deleted.

6 changes: 3 additions & 3 deletions src/NServiceBus.Heartbeat/NServiceBus.Heartbeat.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>$(SolutionDir)NServiceBus.snk</AssemblyOriginatorKeyFile>
<AssemblyOriginatorKeyFile>..\NServiceBus.snk</AssemblyOriginatorKeyFile>
<Description>Send heartbeat monitoring messages from NServiceBus endpoints</Description>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NServiceBus" Version="9.0.0-alpha.2" />
<PackageReference Include="NServiceBus" Version="[9.0.0, 10.0.0)" />
</ItemGroup>

<ItemGroup>
Expand Down
12 changes: 3 additions & 9 deletions src/NServiceBus.Heartbeat/ServiceControlBackend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
{
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Performance.TimeToBeReceived;
using Routing;
using SimpleJson;
using Transport;

class ServiceControlBackend
Expand All @@ -24,10 +23,7 @@ public Task Send(object messageToSend, TimeSpan timeToBeReceived, IMessageDispat
return Send(body, messageToSend.GetType().FullName, timeToBeReceived, dispatcher, cancellationToken);
}

internal static byte[] Serialize(object messageToSend)
{
return Encoding.UTF8.GetBytes(SimpleJson.SerializeObject(messageToSend, serializerStrategy));
}
internal static byte[] Serialize(object messageToSend) => JsonSerializer.SerializeToUtf8Bytes(messageToSend);

Task Send(byte[] body, string messageType, TimeSpan timeToBeReceived, IMessageDispatcher dispatcher, CancellationToken cancellationToken)
{
Expand All @@ -50,9 +46,7 @@ Task Send(byte[] body, string messageType, TimeSpan timeToBeReceived, IMessageDi
}

readonly string sendIntent = MessageIntent.Send.ToString();
string destinationQueue;
readonly string destinationQueue;
readonly ReceiveAddresses receiveAddresses; // note that ReceiveAddresses will be null on send-only endpoints

static IJsonSerializerStrategy serializerStrategy = new MessageSerializationStrategy();
}
}
Loading

0 comments on commit 5676f89

Please sign in to comment.