Skip to content

Instantly share code, notes, and snippets.

View ramonsmits's full-sized avatar

Ramon Smits ramonsmits

View GitHub Profile
@ramonsmits
ramonsmits / ServiceControlCleanup.cs
Created June 18, 2025 13:06
ServiceControl cleanup FailedMessages based on `AddressOfFailingEndpoint`
using Raven.Client.Documents;
using Raven.Client.Documents.Operations;
string FailingEndpointName = args.Length >= 1
? args[0]
: throw new ArgumentException("Missing endpoint name");
int ChunkSize = args.Length >= 2 ? int.Parse(args[1]) : 10000;
@ramonsmits
ramonsmits / WatchdogFeature.cs
Created June 10, 2025 08:51
NServiceBus - Watchdog that will execute a FailFast is no message processing happened for 5 minutes
sealed class WatchdogBehavior : Behavior<IIncomingLogicalMessageContext>, IDisposable
{
static readonly TimeSpan watchdogTimeout = TimeSpan.FromMinutes(5);
static volatile long lastActivityTicks = DateTime.UtcNow.Ticks;
static Thread? watchdogThread;
static CancellationTokenSource? cancellationTokenSource;
public WatchdogBehavior()
{
StartWatchdog();
@ramonsmits
ramonsmits / HeartbeatTouchBehavior.cs
Created June 10, 2025 08:28
NServiceBus - Touch a heartbeat file for external watchdog like monitoring
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using NServiceBus.Pipeline;
sealed class HeartbeatTouchBehavior : Behavior<IIncomingLogicalMessageContext>
{
static readonly string filePath = "C:/watchdog/heartbeat.txt";
static readonly TimeSpan interval = TimeSpan.FromMinutes(1);
@ramonsmits
ramonsmits / LoggerScopeBehavior.cs
Last active June 4, 2025 11:55
NServiceBus - Create a logger scope for every incoming message so each log entry can be correlated to a incomming message processing attempt
using System;
using System.ComponentModel;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NServiceBus;
using NServiceBus.Pipeline;
[Description("Create a logger scope for every incoming message with incoming message processing attemps meta data so this is logged with every log statement")]
@ramonsmits
ramonsmits / platform-queues.md
Last active May 29, 2025 12:17
Particular platfrom queue ownership

Queues used by the various Particular Platform instances

Queue Error Audit Monitoring
audit CR
error CR
particular.monitoring CR
particular.servicecontrol CR W
particular.servicecontrol.errors CW
@ramonsmits
ramonsmits / btrfs-snapshots.md
Created May 19, 2025 11:03
Create, list, and delete Btrfs snapshots

Create

sudo btrfs subvolume snapshot / /.snapshots/$(date +%F_%T)

Delete

sudo btrfs subvolume delete /.snapshots/2024-05-19_14:22:31

List

sudo btrfs subvolume list /
@ramonsmits
ramonsmits / UnsubscribeHostedService.cs
Created May 8, 2025 07:59
NServiceBus - Unsubscribe from events during startup
using System;
using Microsoft.Extensions.Hosting;
class UnsubscribeHostedService(IMessageSession messageSession : BackgroundService
{
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
await messageSession.Unsubscribe<MyEvent>();
}
}
@ramonsmits
ramonsmits / nlog.config
Created February 21, 2025 21:18
ServiceControl audit trace logging but excluding very chatty loggers
<?xml version="1.0" encoding="utf-8" ?>
<!--
ServiceControl audit trace logging but excluding very chatty loggers which should use Trace/Verbose log level but
that log level is not available in NServiceBus.Logging....
Also uses UTC as time reference
See https://docs.particular.net/servicecontrol/logging#customize-logging
-->
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
@ramonsmits
ramonsmits / .md
Last active February 21, 2025 08:51
ServiceControl external RavenDB setup
@ramonsmits
ramonsmits / .md
Last active February 20, 2025 08:19
Azure disk benchmarks
Drive Storage type Size (GiB) Max IOPS Max throughput (MBps) Encryption Host caching
C: Premium SSD LRS 127 500 100 SSE with PMK Read/Write
E: Premium SSD LRS 2048 7500 250 SSE with PMK Read-only
F: Premium SSD v2 LRS 2048 3000 125 SSE with PMK None
G: Ultra disk LRS 2048 7500 240 SSE with PMK None