From b3c8903a8f6f77a3ceb462466c5ac505d253fe29 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Mon, 4 Feb 2019 17:54:15 +1000 Subject: [PATCH 01/36] WIP --- Build.ps1 | 49 ++++++++ Seq.Input.RabbitMQ.sln | 53 ++++++++ example/Demo/Demo.csproj | 14 +++ example/Demo/Program.cs | 28 +++++ src/Seq.Input.RabbitMQ/RabbitMQInput.cs | 114 ++++++++++++++++++ src/Seq.Input.RabbitMQ/RabbitMQListener.cs | 57 +++++++++ .../Seq.Input.RabbitMQ.csproj | 17 +++ .../Seq.Input.RabbitMQ.Tests.csproj | 15 +++ test/Seq.Input.RabbitMQ.Tests/UnitTest1.cs | 14 +++ 9 files changed, 361 insertions(+) create mode 100644 Build.ps1 create mode 100644 Seq.Input.RabbitMQ.sln create mode 100644 example/Demo/Demo.csproj create mode 100644 example/Demo/Program.cs create mode 100644 src/Seq.Input.RabbitMQ/RabbitMQInput.cs create mode 100644 src/Seq.Input.RabbitMQ/RabbitMQListener.cs create mode 100644 src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj create mode 100644 test/Seq.Input.RabbitMQ.Tests/Seq.Input.RabbitMQ.Tests.csproj create mode 100644 test/Seq.Input.RabbitMQ.Tests/UnitTest1.cs diff --git a/Build.ps1 b/Build.ps1 new file mode 100644 index 0000000..34a2dc5 --- /dev/null +++ b/Build.ps1 @@ -0,0 +1,49 @@ +# This script originally (c) 2016 Serilog Contributors - license Apache 2.0 + +echo "build: Build started" + +Push-Location $PSScriptRoot + +if(Test-Path .\artifacts) { + echo "build: Cleaning .\artifacts" + Remove-Item .\artifacts -Force -Recurse +} + +& dotnet restore --no-cache +if($LASTEXITCODE -ne 0) { exit 1 } + +$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL]; +$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL]; +$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "master" -and $revision -ne "local"] + +echo "build: Version suffix is $suffix" + +foreach ($src in ls src/*) { + Push-Location $src + + echo "build: Packaging project in $src" + + if ($suffix) { + & dotnet publish -c Release -o ./obj/publish --version-suffix=$suffix + & dotnet pack -c Release -o ..\..\artifacts --no-build --version-suffix=$suffix + } else { + & dotnet publish -c Release -o ./obj/publish + & dotnet pack -c Release -o ..\..\artifacts --no-build + } + if($LASTEXITCODE -ne 0) { exit 1 } + + Pop-Location +} + +foreach ($test in ls test/*.Tests) { + Push-Location $test + + echo "build: Testing project in $test" + + & dotnet test -c Release + if($LASTEXITCODE -ne 0) { exit 3 } + + Pop-Location +} + +Pop-Location diff --git a/Seq.Input.RabbitMQ.sln b/Seq.Input.RabbitMQ.sln new file mode 100644 index 0000000..d21bbff --- /dev/null +++ b/Seq.Input.RabbitMQ.sln @@ -0,0 +1,53 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.102 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sln", "sln", "{7D1D14F7-D40D-43EB-8CC0-04B555758178}" + ProjectSection(SolutionItems) = preProject + Build.ps1 = Build.ps1 + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{704915B0-6D95-4CF8-ACC2-5ED939A2913C}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{BE42997A-5927-46E1-AFB5-C1D7A255212E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Seq.Input.RabbitMQ", "src\Seq.Input.RabbitMQ\Seq.Input.RabbitMQ.csproj", "{E80E7949-A3AE-4C7C-9083-9FE9EE1F78E0}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Seq.Input.RabbitMQ.Tests", "test\Seq.Input.RabbitMQ.Tests\Seq.Input.RabbitMQ.Tests.csproj", "{9FF2C707-DD8D-4B9C-97A7-4E9F0D9D0008}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "example", "example", "{584683E5-0578-42F0-A958-3AAB3661AA9E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Demo", "example\Demo\Demo.csproj", "{99D4AAE3-35B3-4BE1-AA5F-7CC8E6B49A07}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E80E7949-A3AE-4C7C-9083-9FE9EE1F78E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E80E7949-A3AE-4C7C-9083-9FE9EE1F78E0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E80E7949-A3AE-4C7C-9083-9FE9EE1F78E0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E80E7949-A3AE-4C7C-9083-9FE9EE1F78E0}.Release|Any CPU.Build.0 = Release|Any CPU + {9FF2C707-DD8D-4B9C-97A7-4E9F0D9D0008}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9FF2C707-DD8D-4B9C-97A7-4E9F0D9D0008}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9FF2C707-DD8D-4B9C-97A7-4E9F0D9D0008}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9FF2C707-DD8D-4B9C-97A7-4E9F0D9D0008}.Release|Any CPU.Build.0 = Release|Any CPU + {99D4AAE3-35B3-4BE1-AA5F-7CC8E6B49A07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {99D4AAE3-35B3-4BE1-AA5F-7CC8E6B49A07}.Debug|Any CPU.Build.0 = Debug|Any CPU + {99D4AAE3-35B3-4BE1-AA5F-7CC8E6B49A07}.Release|Any CPU.ActiveCfg = Release|Any CPU + {99D4AAE3-35B3-4BE1-AA5F-7CC8E6B49A07}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {E80E7949-A3AE-4C7C-9083-9FE9EE1F78E0} = {704915B0-6D95-4CF8-ACC2-5ED939A2913C} + {9FF2C707-DD8D-4B9C-97A7-4E9F0D9D0008} = {BE42997A-5927-46E1-AFB5-C1D7A255212E} + {99D4AAE3-35B3-4BE1-AA5F-7CC8E6B49A07} = {584683E5-0578-42F0-A958-3AAB3661AA9E} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {2DD287FB-EAAA-422B-BA1E-B1C91CCC0100} + EndGlobalSection +EndGlobal diff --git a/example/Demo/Demo.csproj b/example/Demo/Demo.csproj new file mode 100644 index 0000000..4686712 --- /dev/null +++ b/example/Demo/Demo.csproj @@ -0,0 +1,14 @@ + + + + netcoreapp2.1 + Exe + + + + + + + + + diff --git a/example/Demo/Program.cs b/example/Demo/Program.cs new file mode 100644 index 0000000..b102872 --- /dev/null +++ b/example/Demo/Program.cs @@ -0,0 +1,28 @@ +using System; +using Serilog; +using Serilog.Formatting.Compact; +using Serilog.Sinks.RabbitMQ.Sinks.RabbitMQ; + +namespace Demo +{ + public class Program + { + public static void Main() + { + var rmq = new RabbitMQConfiguration + { + Hostname = "localhost" + }; + + Log.Logger = new LoggerConfiguration() + .Enrich.WithProperty("Application", "Demo") + .WriteTo.RabbitMQ(rmq, new CompactJsonFormatter()) + .CreateLogger(); + + while (true) + { + Log.Information("Yo, RabbitMQ!"); + } + } + } +} diff --git a/src/Seq.Input.RabbitMQ/RabbitMQInput.cs b/src/Seq.Input.RabbitMQ/RabbitMQInput.cs new file mode 100644 index 0000000..2ecab7f --- /dev/null +++ b/src/Seq.Input.RabbitMQ/RabbitMQInput.cs @@ -0,0 +1,114 @@ +using System; +using System.IO; +using System.Text; +using Seq.Apps; + +namespace Seq.Input.RabbitMQ +{ + [SeqApp("RabbitMQ Input", + Description = "Pulls JSON-formatted events from a RabbitMQ queue. For details of the " + + "supported JSON schema, see " + + "https://github.com/serilog/serilog-formatting-compact/#format-details.")] + public class RabbitMQInput : SeqApp, IPublishJson, IDisposable + { + RabbitMQListener _listener; + + [SeqAppSetting( + DisplayName = "RabbitMQ host", + IsOptional = true, + HelpText = "The hostname on which RabbitMQ is running. The default is `localhost`.")] + public string RabbitMQHost { get; set; } = "localhost"; + + [SeqAppSetting( + DisplayName = "RabbitMQ port", + IsOptional = true, + HelpText = "The port on which the RabbitMQ server is listening. The default is `5762`.")] + public int RabbitMQPort { get; set; } = 5762; + + [SeqAppSetting( + DisplayName = "RabbitMQ user", + IsOptional = true, + HelpText = "The username provided when connecting to RabbitMQ. The default is to connect" + + "anonymously.")] + public string RabbitMQUser { get; set; } + + [SeqAppSetting( + DisplayName = "RabbitMQ password", + IsOptional = true, + InputType = SettingInputType.Password, + HelpText = "The password provided when connecting to RabbitMQ. The default is no password.")] + public string RabbitMQPassword { get; set; } + + [SeqAppSetting( + DisplayName = "RabbitMQ queue", + IsOptional = true, + HelpText = "The RabbitMQ queue name to receive events from. The default is `Logs`.")] + public string RabbitMQQueue { get; set; } = "Logs"; + + [SeqAppSetting( + DisplayName = "Durable", + IsOptional = true, + HelpText = "Whether or not the queue is durable. The default is false.")] + public bool IsQueueDurable { get; set; } + + [SeqAppSetting( + DisplayName = "Exclusive", + IsOptional = true, + HelpText = "Whether or not the queue is exclusive. The default is false.")] + public bool IsQueueExclusive { get; set; } + + [SeqAppSetting( + DisplayName = "Auto-delete", + IsOptional = true, + HelpText = "Whether or not the queue subscription is durable. The default is false.")] + public bool IsQueueAutoDelete { get; set; } + + [SeqAppSetting( + DisplayName = "Auto-ACK", + IsOptional = true, + HelpText = "Whether or not messages should be auto-acknowledged. The default is true.")] + public bool IsReceiveAutoAck { get; set; } = true; + + public void Start(TextWriter inputWriter) + { + var sync = new object(); + void Receive(byte[] body) + { + try + { + lock (sync) + { + var clef = Encoding.UTF8.GetString(body); + inputWriter.WriteLine(clef); + } + } + catch (Exception ex) + { + Log.Error(ex, "A received message could not be decoded"); + } + } + + _listener = new RabbitMQListener( + Receive, + RabbitMQHost ?? "localhost", + RabbitMQPort, + RabbitMQUser, + RabbitMQPassword, + RabbitMQQueue, + IsQueueDurable, + IsQueueAutoDelete, + IsQueueExclusive, + IsReceiveAutoAck); + } + + public void Stop() + { + _listener.Close(); + } + + public void Dispose() + { + _listener.Dispose(); + } + } +} diff --git a/src/Seq.Input.RabbitMQ/RabbitMQListener.cs b/src/Seq.Input.RabbitMQ/RabbitMQListener.cs new file mode 100644 index 0000000..ef417b0 --- /dev/null +++ b/src/Seq.Input.RabbitMQ/RabbitMQListener.cs @@ -0,0 +1,57 @@ +using System; +using RabbitMQ.Client; +using RabbitMQ.Client.Events; + +namespace Seq.Input.RabbitMQ +{ + class RabbitMQListener : IDisposable + { + readonly IConnection _connection; + readonly IModel _channel; + + public RabbitMQListener( + Action receive, + string rabbitMQHost, + int rabbitMQPort, + string rabbitMQUser, + string rabbitMQPassword, + string rabbitMQQueue, + bool isQueueDurable, + bool isQueueAutoDelete, + bool isQueueExclusive, + bool isReceiveAutoAck) + { + var factory = new ConnectionFactory { + HostName = rabbitMQHost, + Port = rabbitMQPort, + UserName = rabbitMQUser, + Password = rabbitMQPassword + }; + + _connection = factory.CreateConnection(); + _channel = _connection.CreateModel(); + + _channel.QueueDeclare( + rabbitMQQueue, + durable: isQueueDurable, + exclusive: isQueueExclusive, + autoDelete: isQueueAutoDelete, + arguments: null); + + var consumer = new EventingBasicConsumer(_channel); + consumer.Received += (model, ea) => receive(ea.Body); + _channel.BasicConsume(rabbitMQQueue, autoAck: isReceiveAutoAck, consumer: consumer); + } + + public void Close() + { + _channel.Close(); + } + + public void Dispose() + { + _channel.Dispose(); + _connection.Close(); + } + } +} \ No newline at end of file diff --git a/src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj b/src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj new file mode 100644 index 0000000..1202993 --- /dev/null +++ b/src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj @@ -0,0 +1,17 @@ + + + + netstandard2.0 + 1.0.0 + + + + + + + + + + + + diff --git a/test/Seq.Input.RabbitMQ.Tests/Seq.Input.RabbitMQ.Tests.csproj b/test/Seq.Input.RabbitMQ.Tests/Seq.Input.RabbitMQ.Tests.csproj new file mode 100644 index 0000000..4ec64e7 --- /dev/null +++ b/test/Seq.Input.RabbitMQ.Tests/Seq.Input.RabbitMQ.Tests.csproj @@ -0,0 +1,15 @@ + + + + netcoreapp2.1 + + false + + + + + + + + + diff --git a/test/Seq.Input.RabbitMQ.Tests/UnitTest1.cs b/test/Seq.Input.RabbitMQ.Tests/UnitTest1.cs new file mode 100644 index 0000000..1cac84f --- /dev/null +++ b/test/Seq.Input.RabbitMQ.Tests/UnitTest1.cs @@ -0,0 +1,14 @@ +using System; +using Xunit; + +namespace Seq.Input.RabbitMQ.Tests +{ + public class UnitTest1 + { + [Fact] + public void Test1() + { + + } + } +} From 1025d3da2c5689ada26c06066210e2efb75a4e93 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Mon, 4 Feb 2019 18:37:54 +1000 Subject: [PATCH 02/36] Don't package Serilog/Apps dlls --- src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj b/src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj index 1202993..087836c 100644 --- a/src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj +++ b/src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj @@ -11,7 +11,7 @@ - + From 76dfa6272b0555fbbce58ea27d1e779c6ef4b4ef Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Mon, 4 Feb 2019 18:55:26 +1000 Subject: [PATCH 03/36] Working! --- example/Demo/Program.cs | 8 +++++++- src/Seq.Input.RabbitMQ/RabbitMQInput.cs | 19 +++++++++---------- src/Seq.Input.RabbitMQ/RabbitMQListener.cs | 7 ++++--- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/example/Demo/Program.cs b/example/Demo/Program.cs index b102872..280d691 100644 --- a/example/Demo/Program.cs +++ b/example/Demo/Program.cs @@ -1,4 +1,5 @@ using System; +using System.Threading; using Serilog; using Serilog.Formatting.Compact; using Serilog.Sinks.RabbitMQ.Sinks.RabbitMQ; @@ -11,7 +12,11 @@ public static void Main() { var rmq = new RabbitMQConfiguration { - Hostname = "localhost" + Hostname = "localhost", + Username = "guest", + Password = "guest", + Exchange = "", + RouteKey = "logs" }; Log.Logger = new LoggerConfiguration() @@ -22,6 +27,7 @@ public static void Main() while (true) { Log.Information("Yo, RabbitMQ!"); + Thread.Sleep(1000); } } } diff --git a/src/Seq.Input.RabbitMQ/RabbitMQInput.cs b/src/Seq.Input.RabbitMQ/RabbitMQInput.cs index 2ecab7f..17ca900 100644 --- a/src/Seq.Input.RabbitMQ/RabbitMQInput.cs +++ b/src/Seq.Input.RabbitMQ/RabbitMQInput.cs @@ -22,28 +22,27 @@ public class RabbitMQInput : SeqApp, IPublishJson, IDisposable [SeqAppSetting( DisplayName = "RabbitMQ port", IsOptional = true, - HelpText = "The port on which the RabbitMQ server is listening. The default is `5762`.")] - public int RabbitMQPort { get; set; } = 5762; + HelpText = "The port on which the RabbitMQ server is listening. The default is `5672`.")] + public int RabbitMQPort { get; set; } = 5672; [SeqAppSetting( DisplayName = "RabbitMQ user", IsOptional = true, - HelpText = "The username provided when connecting to RabbitMQ. The default is to connect" + - "anonymously.")] - public string RabbitMQUser { get; set; } + HelpText = "The username provided when connecting to RabbitMQ. The default is `guest`.")] + public string RabbitMQUser { get; set; } = "guest"; [SeqAppSetting( DisplayName = "RabbitMQ password", IsOptional = true, InputType = SettingInputType.Password, - HelpText = "The password provided when connecting to RabbitMQ. The default is no password.")] - public string RabbitMQPassword { get; set; } + HelpText = "The password provided when connecting to RabbitMQ. The default is `guest`.")] + public string RabbitMQPassword { get; set; } = "guest"; [SeqAppSetting( DisplayName = "RabbitMQ queue", IsOptional = true, HelpText = "The RabbitMQ queue name to receive events from. The default is `Logs`.")] - public string RabbitMQQueue { get; set; } = "Logs"; + public string RabbitMQQueue { get; set; } = "logs"; [SeqAppSetting( DisplayName = "Durable", @@ -90,7 +89,7 @@ void Receive(byte[] body) _listener = new RabbitMQListener( Receive, - RabbitMQHost ?? "localhost", + RabbitMQHost, RabbitMQPort, RabbitMQUser, RabbitMQPassword, @@ -108,7 +107,7 @@ public void Stop() public void Dispose() { - _listener.Dispose(); + _listener?.Dispose(); } } } diff --git a/src/Seq.Input.RabbitMQ/RabbitMQListener.cs b/src/Seq.Input.RabbitMQ/RabbitMQListener.cs index ef417b0..f614d63 100644 --- a/src/Seq.Input.RabbitMQ/RabbitMQListener.cs +++ b/src/Seq.Input.RabbitMQ/RabbitMQListener.cs @@ -21,7 +21,8 @@ public RabbitMQListener( bool isQueueExclusive, bool isReceiveAutoAck) { - var factory = new ConnectionFactory { + var factory = new ConnectionFactory + { HostName = rabbitMQHost, Port = rabbitMQPort, UserName = rabbitMQUser, @@ -50,8 +51,8 @@ public void Close() public void Dispose() { - _channel.Dispose(); - _connection.Close(); + _channel?.Dispose(); + _connection?.Close(); } } } \ No newline at end of file From f65f0a93bdda1178ac9ca0d09a7bb65179d104d2 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Tue, 5 Feb 2019 10:07:09 +1000 Subject: [PATCH 04/36] Update LICENSE to include information about packaged components --- .gitattributes | 4 +++ LICENSE | 17 +++++++++++++ appveyor.yml | 24 ++++++++++++++++++ asset/seq-input-rabbitmq.png | Bin 0 -> 4224 bytes ...put.RabbitMQ.sln => seq-input-rabbitmq.sln | 2 ++ .../Seq.Input.RabbitMQ.csproj | 12 +++++++++ 6 files changed, 59 insertions(+) create mode 100644 .gitattributes create mode 100644 appveyor.yml create mode 100644 asset/seq-input-rabbitmq.png rename Seq.Input.RabbitMQ.sln => seq-input-rabbitmq.sln (98%) diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..eebc8cb --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +# Auto detect text files and perform LF normalization + +* text=auto +*.sh text eol=lf diff --git a/LICENSE b/LICENSE index 261eeb9..d4165e1 100644 --- a/LICENSE +++ b/LICENSE @@ -1,3 +1,20 @@ +Seq.Input.RabbitMQ is Copyright (c) 2019 Datalust Pty Ltd and Contributors, +provided subject to the Apache License, Version 2.0. + +The Seq.Input.RabbitMQ NuGet package includes binary components licensed by +their respective copyright owners, including but not limited to: + + * .NET CoreFX components (System.*.dll) - MIT License, + https://github.com/dotnet/corefx/blob/master/LICENSE.TXT + + * Microsoft .NET libraries (System.*.dll) - MS-.NET-Library License, + https://dotnet.microsoft.com/dotnet_library_license.htm + + * RabbitMQ.Client.dll - Apache 2.0 license, + http://www.rabbitmq.com/dotnet.html + +--- + Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..7d14cc3 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,24 @@ +version: '{build}' +skip_tags: true +image: Visual Studio 2017 +configuration: Release +install: +build_script: +- ps: ./Build.ps1 +test: off +artifacts: +- path: artifacts/Seq.Input.RabbitMQ.*.nupkg +deploy: +- provider: NuGet + api_key: + secure: XqbN2YjJ/L0u8RG4uyFzPm6Qf5Bhy+80n9+WyNs9p19ZqdRCurea87gMxbXR93Wi + skip_symbols: true + on: + branch: /^(master|dev)$/ +- provider: GitHub + auth_token: + secure: hX+cZmW+9BCXy7vyH8myWsYdtQHyzzil9K5yvjJv7dK9XmyrGYYDj/DPzMqsXSjo + artifact: /Seq.Input.RabbitMQ.*\.nupkg/ + tag: v$(appveyor_build_version) + on: + branch: master diff --git a/asset/seq-input-rabbitmq.png b/asset/seq-input-rabbitmq.png new file mode 100644 index 0000000000000000000000000000000000000000..5db3771fadb53276b072d2eafaad9dd0897da55a GIT binary patch literal 4224 zcmai1dpJ~U7vD3Pnnp5?F)rnDq)f=IQW-H*!${O9_xpWvi(H0c7;;=9aym#FjYP1$mGn&jlY!hZx#~ zTn_LG33Cnd1j53?)V;6z2D`fkda4Hmk#iRHWB@>P^Be(h5&nQTIv?z?LT&%H6kshg zR;eYl{%kw+@-XH#G_na&NREXibMROqQ2lzMN0#P~oYqq(X5F59ZLmHpkl5#7IZ%c~m7-L9@E` zv#63>09mkk7J?gnvd(7Z7*4tI^vqu&0L#tIP2uW?3+tjj65`9J-%q)iVxkf!tOAf<@BvqV$1UCEjULWiULYv zsRj>hAe!z&eyiu}&ba1F1vgUArXnz!bf*_H+Hdlk*MaW|TwBf1QsCY*(1*)O?Q7Z_ z6NV6%*QG2G^4ew=!K0iaXDY7>6e>OJan4jlpSaZ##$vjB!2pr2bqGW}Jey=Lf{gi}Jdo7WiLzu#HZAtr3fWEc< z!)-6a$F>CaBRY)5LC|_SzAUHRXj>4AZ(KA71pReX=alPCgfCZS@VqK0j-Wrf=8R4c z@FmAYV*q2&dSHmU?ZZ>!ORC~pJePke>$!gtk2m-`973>AOuu(LY-=OBYGA95f}YI- z6fuq}M^fvq-es-s<*B`EMIg269IhI^2^CF(b3_peCe=ST#C6ca>Wa|}I;^<~frKOx z+y+LjFGrDY|IDDEg@j?G8StE27Ut!3-Wn+fmCi!?t0MKIYma}CPz@>oRm4xwbVFB{ z)`z8|9N-!>-Mhw0UT@j6kD?{goqfo7zBv%8l=D_SJ-p!@A=8(PKUoRwPXbp+Yne=l zn`lRofY9*;_Shjs>nmjZ^Gax(O<364Lfa5?+l(ML*c}`A2sopX)kPg@b2C#6%Aug+ zK-b{~%Re)8&{(BC240C!c($MZHsQ@ZE3rBUtnjNe2?eF@#r17<#WZg+ev<*5Q2_02 z-KxA)t4*=OUxih1O`eFq0)}lCkeoC-1^|6+=d0cNc}ynV{}nq;#uWxGMTW`z|?Pdx|y#nJ<=kRjc!Fh2enNx=TrKKZ+1rCuwQ zUg1rK6yB0>*$IY6)L)H)lZuK%Y0$jGf6YB{H;DMr`{ecX_pziziS(n~><#46Lak5l zG%sRzl_Ws##j|_|yXB;_pD&d>%_8u+^vH7I<6F5fVRWP+77h~1<-U{ejnLNFkFyEf zQ<2Xq%lwH24(g)byYQhTpwC0~nJb6cFxgf#H1j|-*@_Xmkn|Ja7FBiX% zh4)`Xa*PZ;EU?KBjflhmgOJ(HFjg=~UYfMZ7vU3&!!Oq=DSI0WE}d45c%OZidrI>t z3MbJJ&7d0UOYGBPHO z?v0(x14>$~{5Wl7C!2-qPIz!f6^XU@vNC^pVPZ4s5m0i)BgDgexy^bf!Nc@7o_OM- zVEiV>+&<oP!_Ly6MOCI3Z_LHKT;J<6!?)KS z3Jp6%k8;NDQcr>Mo13ZYON&QPVZJkb+lI~YJl}+bgj0x}Qn2y6g(5kN_oU?4jj;(2 zOEb>f)v|5}q4uaFnv`>Aj$aMGx|xwXBf(+{I?F7sj(mD{AjmlrA&h7uayXo<#@>-2 zla@^It+z{HV5?YaYzzS+P`hiQaXNDL<|g;lMy4^PtV0s9ab42|1HdA}7VU-xhxf7a zT{saDYtC=YHEl4!K{E}1yT#0|_L^Wpm(zuEo03|5jf1RP{w{!kF%b+y9E@Y>tU(4QSl*vLiU~)S`4pqkrY*x2F<$U6)iq_~#G(Q7gAS zJL?3lJb$wH8ZnQQ(yxK>21}~T`hfphu1bbtIBF#9AhDSXmg&zQBu_*=)srsEXV^qs zpC5R3Iaji*$54<2h3_5=o$<4)jfz=m=;PXM96M#}^lP!cUUALya3cx$Q#;UWyd>;d z!-oTk5+IJROH0nze|*$RjXjQo#HI9QKVK14xtrJTGHy@0+jX8=khmFpiDwS{Su@G= zSMAwYn=7I^gb$RD)@$tBCwm)&_(2ASJTqX&ock;5>NUp`d0_AdUQ5{95C1xeuo8tK zFWsH)yuL3t!ZnqpV@GWMKJ|7#>}diNUKMkcoY}DaCFgL`XLJ6QABzes5W$1KbitQS zcV)$}KbK}t)|G~QwRjwbFGgc%y6=9iV%Ks{Q4fJx9I781eHrNIrg*85Vd0O$$yN^B zH`6F@Yze#TtD}$xR_7NfdNu5cZ*EI|p^O|q%`Ay8Jsj0US6kZZ{{)vxF z%?`$m3lA3?y?6o9C*C7{Pv+BGH3n?3Bld;{&_nw zoa_1(0;5$*>A1;VeEf$Q7yorPj5f~v8<}pI6cSsp!&>?TAaq}BIdfld7S=mqq5|Rs zz*SU@29z%CUfq;=1Rx1#trpxnEvgN%#xL^$Q1Dkn;Rd?!s|=yU7K=?h#} z0rizIfNvUG%OC;obgtZ{s%4w73uTpVVSu74w~K8`&t9K9)%#064H~x(2$8zZY2)#d za)me*iITuZ8(Urh1#BF{7)32Ue(;uy=kG=UQFDpeA4|F|$O#nWhTI9DKR3fHxP3<5 zU2ro&67VTjw8{;6-z_6n#dYP|q5z-inwF_27iyW7Sa^3D6nA8Q($L4V^ijGa7a!<4 z0+1|?-n7+C23v;|N^fb7!)QLmi5be`b1eqoXF!q&VaWV)*I6|tzxcgCVLY_Slq!`a zIIG;JT+h1c@)ZM^=1A1L`UNdm|BQ^XzzP>8K$}9IyG<8+=ytN@gHS->*MG<_i7(ze z`g8G`!5h-Z%h#Sa9~)`o4~jYgf=5pK>HDd%)J8T55Nv~Xhn0DiOM`zR0Lh@&w>Hmd z(?`l>g;;pVc%*(&i;8F{*dtxph35qdwanNWI7v6=OjJZS0Q|B8r|qRV|Yh+WNc`d9Cdpi>ZD;RFWfa)&M;6ePy?P;zHW8JQvSM zfF>3;NZHaC&Mgk^g*ui3z06v3nXFTX6DD@SkO#pIdHuqV2N++u zZDu3W8%-Yn(PM0aMZ~5;i!_F8)SkUy)-xTk@K-U=BJqKbqq*PYC@<(vJT+i>{(XT==h#Fb#Z_DVebSy)eQzO1XhruGJnYb5$8>_VW`B&d0$XTJ@ zvyj=KQnK~Iqn-I&Jko3g_(w`BpswxZ?TLg#PQVt^&BF`~^uL@%`lD!#@hSJ(#fu3{ z3i5Z8n3fTjSZeZEyuBtLm zKSV}LRQGiEZk|HZUx7P{*hid3>~m+&X>P#voPZC(i_04e>u?bSLw9FuM-TlUrY#n( zDS>Kw6WU_xXGtz$o&{yg5y0zJ$NYOt?a>WfoSJR5NB7F0!}gk@TMhI7{!@br3iq~l XjqCWJ!=b8ezxB@ netstandard2.0 1.0.0 + Ingest events into Seq directly from RabbitMQ + Datalust and Contributors + seq-app + https://raw.githubusercontent.com/datalust/sqelf/master/asset/seq-input-gelf.png + https://github.com/datalust/seq-input-rabbitmq + https://www.apache.org/licenses/LICENSE-2.0 + https://github.com/datalust/seq-input-rabbitmq + git + True + + LICENSE @@ -11,6 +22,7 @@ + From fa27d9cdc3efd2de09d5e546e56adee19132daf6 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Tue, 5 Feb 2019 10:09:25 +1000 Subject: [PATCH 05/36] Update README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b50a39d..cc9dee9 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ -# seq-input-rabbitmq -An example Seq custom input that pulls events from RabbitMQ +# Seq.Input.RabbitMQ + +A Seq custom input that pulls events from RabbitMQ. From c19e1d7030929629c9c09c190ba3fb8b6f55250a Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Tue, 5 Feb 2019 10:10:29 +1000 Subject: [PATCH 06/36] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cc9dee9..622c0e0 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ -# Seq.Input.RabbitMQ +# Seq.Input.RabbitMQ [![Build status](https://ci.appveyor.com/api/projects/status/uq432micob0lpiu4?svg=true)](https://ci.appveyor.com/project/datalust/seq-input-rabbitmq) A Seq custom input that pulls events from RabbitMQ. From 03dcce1e645449669006d596562247f132d86ac3 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Tue, 5 Feb 2019 10:34:19 +1000 Subject: [PATCH 07/36] Remove redundant --- src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj b/src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj index 3f38997..15f0180 100644 --- a/src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj +++ b/src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj @@ -1,5 +1,4 @@ - - + netstandard2.0 1.0.0 @@ -8,7 +7,6 @@ seq-app https://raw.githubusercontent.com/datalust/sqelf/master/asset/seq-input-gelf.png https://github.com/datalust/seq-input-rabbitmq - https://www.apache.org/licenses/LICENSE-2.0 https://github.com/datalust/seq-input-rabbitmq git True From abe7bc3c8e3e013f20631a0f681d38948a5ccf94 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Tue, 5 Feb 2019 10:37:57 +1000 Subject: [PATCH 08/36] Update build badge [skip ci] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 622c0e0..43f49c1 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ -# Seq.Input.RabbitMQ [![Build status](https://ci.appveyor.com/api/projects/status/uq432micob0lpiu4?svg=true)](https://ci.appveyor.com/project/datalust/seq-input-rabbitmq) +# Seq.Input.RabbitMQ [![Build status](https://ci.appveyor.com/api/projects/status/lxab9qqdtqupk6y4?svg=true)](https://ci.appveyor.com/project/datalust/seq-input-rabbitmq) A Seq custom input that pulls events from RabbitMQ. From c9c601f209f7bfb92a34048bfbedf7a7dc796ee0 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Tue, 5 Feb 2019 11:41:55 +1000 Subject: [PATCH 09/36] Fix NuGet.org publishing key --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 7d14cc3..27d21e5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,7 +11,7 @@ artifacts: deploy: - provider: NuGet api_key: - secure: XqbN2YjJ/L0u8RG4uyFzPm6Qf5Bhy+80n9+WyNs9p19ZqdRCurea87gMxbXR93Wi + secure: 1aikaDXBKMKvsGQrmweRt4UI2EjEkdmE+8HpDZyWvlVyt+rwBH4QS3XOw7rf2QUQ skip_symbols: true on: branch: /^(master|dev)$/ From d0aeb872c0d90154806ae504e1616c5c0d4d05c6 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Tue, 5 Feb 2019 14:13:54 +1000 Subject: [PATCH 10/36] More README [skip ci] --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 43f49c1..750f2d1 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,15 @@ # Seq.Input.RabbitMQ [![Build status](https://ci.appveyor.com/api/projects/status/lxab9qqdtqupk6y4?svg=true)](https://ci.appveyor.com/project/datalust/seq-input-rabbitmq) A Seq custom input that pulls events from RabbitMQ. + +### Getting started + +The app is published to NuGet as [_Seq.Input.RabbitMQ_](https://nuget.org/packages/seq.input.rabbitmq). Follow the instructions for [installing a Seq App](https://docs.getseq.net/docs/installing-seq-apps) and start an instance of the app, providing your RabbitMQ server details. + +### Sending events to the input + +The input accepts events in [compact JSON format](https://github.com/serilog/serilog-formatting-compact#format-details), encoded as UTF-8 text. + +The [_Serilog.Sinks.RabbitMQ_ sink](https://github.com/sonicjolt/serilog-sinks-rabbitmq), along with the [_Serilog.Formatting.Compact_ formatter](https://github.com/serilog/serilog-formatting-compact), can be used for this. + +See the _Demo_ project included in the repository for an example of client configuration that works with the default input configuration. From 930621435c4c85cc63705f50df4fb594814ff769 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Tue, 5 Feb 2019 14:14:34 +1000 Subject: [PATCH 11/36] Note required Seq version [skip ci] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 750f2d1..34a1eb3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Seq.Input.RabbitMQ [![Build status](https://ci.appveyor.com/api/projects/status/lxab9qqdtqupk6y4?svg=true)](https://ci.appveyor.com/project/datalust/seq-input-rabbitmq) -A Seq custom input that pulls events from RabbitMQ. +A Seq custom input that pulls events from RabbitMQ. **Requires Seq 5.1+.** ### Getting started From 52fa1091fd8c5e2ee5a9adf76ffd867baf83350a Mon Sep 17 00:00:00 2001 From: Eric Tummers Date: Thu, 9 Feb 2023 18:18:22 +0100 Subject: [PATCH 12/36] Added RabbitMQVHost --- src/Seq.Input.RabbitMQ/RabbitMQInput.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Seq.Input.RabbitMQ/RabbitMQInput.cs b/src/Seq.Input.RabbitMQ/RabbitMQInput.cs index 17ca900..79be1a1 100644 --- a/src/Seq.Input.RabbitMQ/RabbitMQInput.cs +++ b/src/Seq.Input.RabbitMQ/RabbitMQInput.cs @@ -19,6 +19,12 @@ public class RabbitMQInput : SeqApp, IPublishJson, IDisposable HelpText = "The hostname on which RabbitMQ is running. The default is `localhost`.")] public string RabbitMQHost { get; set; } = "localhost"; + [SeqAppSetting( + DisplayName = "RabbitMQ vhost", + IsOptional = true, + HelpText = "The virtual host in RabbitMQ. The default is `/`.")] + public string RabbitMQVHost { get; set; } = "/"; + [SeqAppSetting( DisplayName = "RabbitMQ port", IsOptional = true, @@ -90,6 +96,7 @@ void Receive(byte[] body) _listener = new RabbitMQListener( Receive, RabbitMQHost, + RabbitMQVHost, RabbitMQPort, RabbitMQUser, RabbitMQPassword, From 2e5c463e8c123808e1b170439611d3aab4c00ac6 Mon Sep 17 00:00:00 2001 From: Eric Tummers Date: Thu, 9 Feb 2023 18:20:09 +0100 Subject: [PATCH 13/36] Added rabbitMQVHost to the constructor --- src/Seq.Input.RabbitMQ/RabbitMQListener.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Seq.Input.RabbitMQ/RabbitMQListener.cs b/src/Seq.Input.RabbitMQ/RabbitMQListener.cs index f614d63..a5bc7ae 100644 --- a/src/Seq.Input.RabbitMQ/RabbitMQListener.cs +++ b/src/Seq.Input.RabbitMQ/RabbitMQListener.cs @@ -11,7 +11,8 @@ class RabbitMQListener : IDisposable public RabbitMQListener( Action receive, - string rabbitMQHost, + string rabbitMQHost, + string rabbitMQVHost, int rabbitMQPort, string rabbitMQUser, string rabbitMQPassword, @@ -24,6 +25,7 @@ public RabbitMQListener( var factory = new ConnectionFactory { HostName = rabbitMQHost, + VirtualHost = rabbitMQVHost, Port = rabbitMQPort, UserName = rabbitMQUser, Password = rabbitMQPassword @@ -55,4 +57,4 @@ public void Dispose() _connection?.Close(); } } -} \ No newline at end of file +} From e3c987913507ba9dca84128dc892b2d862c90510 Mon Sep 17 00:00:00 2001 From: Eric Tummers Date: Fri, 10 Feb 2023 15:16:12 +0100 Subject: [PATCH 14/36] added IsSsl --- src/Seq.Input.RabbitMQ/RabbitMQInput.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Seq.Input.RabbitMQ/RabbitMQInput.cs b/src/Seq.Input.RabbitMQ/RabbitMQInput.cs index 79be1a1..098d352 100644 --- a/src/Seq.Input.RabbitMQ/RabbitMQInput.cs +++ b/src/Seq.Input.RabbitMQ/RabbitMQInput.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using System.Text; using Seq.Apps; @@ -50,6 +50,12 @@ public class RabbitMQInput : SeqApp, IPublishJson, IDisposable HelpText = "The RabbitMQ queue name to receive events from. The default is `Logs`.")] public string RabbitMQQueue { get; set; } = "logs"; + [SeqAppSetting( + DisplayName = "Ssl", + IsOptional = true, + HelpText = "Whether or not the connection is with ssl. The default is false.")] + public bool IsSsl { get; set; } + [SeqAppSetting( DisplayName = "Durable", IsOptional = true, @@ -77,13 +83,13 @@ public class RabbitMQInput : SeqApp, IPublishJson, IDisposable public void Start(TextWriter inputWriter) { var sync = new object(); - void Receive(byte[] body) + void Receive(ReadOnlyMemory body) { try { lock (sync) { - var clef = Encoding.UTF8.GetString(body); + var clef = body.ToString(); inputWriter.WriteLine(clef); } } @@ -101,6 +107,7 @@ void Receive(byte[] body) RabbitMQUser, RabbitMQPassword, RabbitMQQueue, + IsSsl, IsQueueDurable, IsQueueAutoDelete, IsQueueExclusive, From b5a9c1a171ffc7eebdef01c628ed798327ecefd3 Mon Sep 17 00:00:00 2001 From: Eric Tummers Date: Fri, 10 Feb 2023 15:16:51 +0100 Subject: [PATCH 15/36] Added IsSsl handling --- src/Seq.Input.RabbitMQ/RabbitMQListener.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Seq.Input.RabbitMQ/RabbitMQListener.cs b/src/Seq.Input.RabbitMQ/RabbitMQListener.cs index a5bc7ae..9755810 100644 --- a/src/Seq.Input.RabbitMQ/RabbitMQListener.cs +++ b/src/Seq.Input.RabbitMQ/RabbitMQListener.cs @@ -1,22 +1,24 @@ -using System; +using System; +using System.Net.Security; using RabbitMQ.Client; using RabbitMQ.Client.Events; namespace Seq.Input.RabbitMQ { - class RabbitMQListener : IDisposable + public class RabbitMQListener : IDisposable { readonly IConnection _connection; readonly IModel _channel; public RabbitMQListener( - Action receive, + Action> receive, string rabbitMQHost, string rabbitMQVHost, int rabbitMQPort, string rabbitMQUser, string rabbitMQPassword, string rabbitMQQueue, + bool IsSsl, bool isQueueDurable, bool isQueueAutoDelete, bool isQueueExclusive, @@ -30,7 +32,15 @@ public RabbitMQListener( UserName = rabbitMQUser, Password = rabbitMQPassword }; - + if (IsSsl) + { + factory.Ssl.AcceptablePolicyErrors = + SslPolicyErrors.RemoteCertificateNameMismatch | + SslPolicyErrors.RemoteCertificateChainErrors | + SslPolicyErrors.RemoteCertificateNotAvailable; + factory.Ssl.Enabled = true; + } + _connection = factory.CreateConnection(); _channel = _connection.CreateModel(); From c0afcf5c615cebad11a744854821d1a081ba7813 Mon Sep 17 00:00:00 2001 From: Eric Tummers Date: Fri, 10 Feb 2023 15:17:33 +0100 Subject: [PATCH 16/36] updated rabbitmq client to 6.4 --- src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj b/src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj index 15f0180..22584dd 100644 --- a/src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj +++ b/src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj @@ -5,7 +5,6 @@ Ingest events into Seq directly from RabbitMQ Datalust and Contributors seq-app - https://raw.githubusercontent.com/datalust/sqelf/master/asset/seq-input-gelf.png https://github.com/datalust/seq-input-rabbitmq https://github.com/datalust/seq-input-rabbitmq git @@ -16,11 +15,11 @@ - + - + From 455c1011d5cdd25e08a845aaefaa68932e49829a Mon Sep 17 00:00:00 2001 From: Eric Tummers Date: Fri, 10 Feb 2023 19:38:39 +0100 Subject: [PATCH 17/36] Byte array to string with Encoding.UTF8 --- src/Seq.Input.RabbitMQ/RabbitMQInput.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Seq.Input.RabbitMQ/RabbitMQInput.cs b/src/Seq.Input.RabbitMQ/RabbitMQInput.cs index 098d352..66f1727 100644 --- a/src/Seq.Input.RabbitMQ/RabbitMQInput.cs +++ b/src/Seq.Input.RabbitMQ/RabbitMQInput.cs @@ -89,7 +89,7 @@ void Receive(ReadOnlyMemory body) { lock (sync) { - var clef = body.ToString(); + var clef = Encoding.UTF8.GetString(body.ToArray()); inputWriter.WriteLine(clef); } } From f61e92ae8eb34ffc8f50860ca4963134f67a88bb Mon Sep 17 00:00:00 2001 From: Eric Tummers Date: Fri, 10 Feb 2023 19:40:29 +0100 Subject: [PATCH 18/36] Seq.Apps version bump --- src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj b/src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj index 22584dd..133247d 100644 --- a/src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj +++ b/src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj @@ -14,7 +14,7 @@ - + From 0527e6915621be0ab5997d09c8a6404fe82392d1 Mon Sep 17 00:00:00 2001 From: Eric Tummers Date: Sat, 11 Feb 2023 11:29:28 +0100 Subject: [PATCH 19/36] Update display name and helptext for clarity --- src/Seq.Input.RabbitMQ/RabbitMQInput.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Seq.Input.RabbitMQ/RabbitMQInput.cs b/src/Seq.Input.RabbitMQ/RabbitMQInput.cs index 66f1727..edc6555 100644 --- a/src/Seq.Input.RabbitMQ/RabbitMQInput.cs +++ b/src/Seq.Input.RabbitMQ/RabbitMQInput.cs @@ -20,7 +20,7 @@ public class RabbitMQInput : SeqApp, IPublishJson, IDisposable public string RabbitMQHost { get; set; } = "localhost"; [SeqAppSetting( - DisplayName = "RabbitMQ vhost", + DisplayName = "RabbitMQ Virtual Host", IsOptional = true, HelpText = "The virtual host in RabbitMQ. The default is `/`.")] public string RabbitMQVHost { get; set; } = "/"; @@ -51,9 +51,9 @@ public class RabbitMQInput : SeqApp, IPublishJson, IDisposable public string RabbitMQQueue { get; set; } = "logs"; [SeqAppSetting( - DisplayName = "Ssl", + DisplayName = "Require SSL", IsOptional = true, - HelpText = "Whether or not the connection is with ssl. The default is false.")] + HelpText = "Whether or not the connection is with SSL. The default is false.")] public bool IsSsl { get; set; } [SeqAppSetting( From 1edc37b400d249c7d2a12a1b0b658416ff65f25d Mon Sep 17 00:00:00 2001 From: Eric Tummers Date: Sat, 11 Feb 2023 11:44:50 +0100 Subject: [PATCH 20/36] Private class and comment for bad practice --- src/Seq.Input.RabbitMQ/RabbitMQListener.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Seq.Input.RabbitMQ/RabbitMQListener.cs b/src/Seq.Input.RabbitMQ/RabbitMQListener.cs index 9755810..c30eeca 100644 --- a/src/Seq.Input.RabbitMQ/RabbitMQListener.cs +++ b/src/Seq.Input.RabbitMQ/RabbitMQListener.cs @@ -5,7 +5,7 @@ namespace Seq.Input.RabbitMQ { - public class RabbitMQListener : IDisposable + class RabbitMQListener : IDisposable { readonly IConnection _connection; readonly IModel _channel; @@ -34,6 +34,7 @@ public RabbitMQListener( }; if (IsSsl) { + // bad practice! but this is needed for now factory.Ssl.AcceptablePolicyErrors = SslPolicyErrors.RemoteCertificateNameMismatch | SslPolicyErrors.RemoteCertificateChainErrors | From 7cc74731db85ccdcdf384bb5b6653d340dde74de Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Tue, 14 Feb 2023 09:14:42 +1000 Subject: [PATCH 21/36] Drop out SSL policy configuration --- src/Seq.Input.RabbitMQ/RabbitMQListener.cs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/Seq.Input.RabbitMQ/RabbitMQListener.cs b/src/Seq.Input.RabbitMQ/RabbitMQListener.cs index c30eeca..30ed239 100644 --- a/src/Seq.Input.RabbitMQ/RabbitMQListener.cs +++ b/src/Seq.Input.RabbitMQ/RabbitMQListener.cs @@ -18,7 +18,7 @@ public RabbitMQListener( string rabbitMQUser, string rabbitMQPassword, string rabbitMQQueue, - bool IsSsl, + bool isSsl, bool isQueueDurable, bool isQueueAutoDelete, bool isQueueExclusive, @@ -30,17 +30,12 @@ public RabbitMQListener( VirtualHost = rabbitMQVHost, Port = rabbitMQPort, UserName = rabbitMQUser, - Password = rabbitMQPassword + Password = rabbitMQPassword, + Ssl = + { + Enabled = isSsl + } }; - if (IsSsl) - { - // bad practice! but this is needed for now - factory.Ssl.AcceptablePolicyErrors = - SslPolicyErrors.RemoteCertificateNameMismatch | - SslPolicyErrors.RemoteCertificateChainErrors | - SslPolicyErrors.RemoteCertificateNotAvailable; - factory.Ssl.Enabled = true; - } _connection = factory.CreateConnection(); _channel = _connection.CreateModel(); From e192c37d3b80f2ab98572fed211cf7d28d0e9754 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Tue, 14 Feb 2023 09:18:05 +1000 Subject: [PATCH 22/36] Update Build.ps1 --- Build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Build.ps1 b/Build.ps1 index 34a2dc5..dc24499 100644 --- a/Build.ps1 +++ b/Build.ps1 @@ -14,7 +14,7 @@ if($LASTEXITCODE -ne 0) { exit 1 } $branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL]; $revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL]; -$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "master" -and $revision -ne "local"] +$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "main" -and $revision -ne "local"] echo "build: Version suffix is $suffix" From e877a84eb76ee97ca4af2a20412b0a9111d22368 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Tue, 14 Feb 2023 09:21:57 +1000 Subject: [PATCH 23/36] Update publishing info --- appveyor.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 27d21e5..4db264c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,6 @@ version: '{build}' skip_tags: true -image: Visual Studio 2017 -configuration: Release +image: Visual Studio 2022 install: build_script: - ps: ./Build.ps1 @@ -11,14 +10,14 @@ artifacts: deploy: - provider: NuGet api_key: - secure: 1aikaDXBKMKvsGQrmweRt4UI2EjEkdmE+8HpDZyWvlVyt+rwBH4QS3XOw7rf2QUQ + secure: HDcRadKRDne9Gd1vEQwZknRQz63ZbZMJh6e4sFmiXCpjkxC5WCoQ0ZecWBHtVulX skip_symbols: true on: - branch: /^(master|dev)$/ + branch: /^(main|dev)$/ - provider: GitHub auth_token: secure: hX+cZmW+9BCXy7vyH8myWsYdtQHyzzil9K5yvjJv7dK9XmyrGYYDj/DPzMqsXSjo artifact: /Seq.Input.RabbitMQ.*\.nupkg/ tag: v$(appveyor_build_version) on: - branch: master + branch: main From 85e6fa67f72742fa5289415394e9ff9b1804a5a6 Mon Sep 17 00:00:00 2001 From: Antonia Elek Date: Thu, 16 Jan 2025 16:36:14 +0100 Subject: [PATCH 24/36] Added dlx parameter. --- src/Seq.Input.RabbitMQ/RabbitMQInput.cs | 9 ++++++++- src/Seq.Input.RabbitMQ/RabbitMQListener.cs | 23 +++++++++++++--------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/Seq.Input.RabbitMQ/RabbitMQInput.cs b/src/Seq.Input.RabbitMQ/RabbitMQInput.cs index edc6555..253e408 100644 --- a/src/Seq.Input.RabbitMQ/RabbitMQInput.cs +++ b/src/Seq.Input.RabbitMQ/RabbitMQInput.cs @@ -80,6 +80,12 @@ public class RabbitMQInput : SeqApp, IPublishJson, IDisposable HelpText = "Whether or not messages should be auto-acknowledged. The default is true.")] public bool IsReceiveAutoAck { get; set; } = true; + [SeqAppSetting( + DisplayName = "Dead Letter Exchange", + IsOptional = true, + HelpText = "Name of dead letter exchange associated with this queue.")] + public string Dlx { get; set; } = "guest"; + public void Start(TextWriter inputWriter) { var sync = new object(); @@ -111,7 +117,8 @@ void Receive(ReadOnlyMemory body) IsQueueDurable, IsQueueAutoDelete, IsQueueExclusive, - IsReceiveAutoAck); + IsReceiveAutoAck, + Dlx); } public void Stop() diff --git a/src/Seq.Input.RabbitMQ/RabbitMQListener.cs b/src/Seq.Input.RabbitMQ/RabbitMQListener.cs index 30ed239..1006e66 100644 --- a/src/Seq.Input.RabbitMQ/RabbitMQListener.cs +++ b/src/Seq.Input.RabbitMQ/RabbitMQListener.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Net.Security; using RabbitMQ.Client; using RabbitMQ.Client.Events; @@ -10,19 +11,19 @@ class RabbitMQListener : IDisposable readonly IConnection _connection; readonly IModel _channel; - public RabbitMQListener( - Action> receive, + public RabbitMQListener(Action> receive, string rabbitMQHost, string rabbitMQVHost, - int rabbitMQPort, - string rabbitMQUser, + int rabbitMQPort, + string rabbitMQUser, string rabbitMQPassword, - string rabbitMQQueue, + string rabbitMQQueue, bool isSsl, - bool isQueueDurable, - bool isQueueAutoDelete, + bool isQueueDurable, + bool isQueueAutoDelete, bool isQueueExclusive, - bool isReceiveAutoAck) + bool isReceiveAutoAck, + string dlx) { var factory = new ConnectionFactory { @@ -40,12 +41,16 @@ public RabbitMQListener( _connection = factory.CreateConnection(); _channel = _connection.CreateModel(); + var arguments = string.IsNullOrWhiteSpace(dlx) + ? null + : new Dictionary { {"x-dead-letter-exchange", dlx} }; + _channel.QueueDeclare( rabbitMQQueue, durable: isQueueDurable, exclusive: isQueueExclusive, autoDelete: isQueueAutoDelete, - arguments: null); + arguments: arguments); var consumer = new EventingBasicConsumer(_channel); consumer.Received += (model, ea) => receive(ea.Body); From ee28cea69073c147f258ec64ce94b4cbb5b28370 Mon Sep 17 00:00:00 2001 From: Ashley Mannix Date: Tue, 21 Jan 2025 09:03:35 +1000 Subject: [PATCH 25/36] port to GitHub Actions --- .github/workflows/ci.yml | 40 +++++++++++++++++ Build.ps1 | 92 ++++++++++++++++++++++++++-------------- appveyor.yml | 23 ---------- 3 files changed, 101 insertions(+), 54 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 appveyor.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..d580450 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,40 @@ +# If this file is renamed, the incrementing run attempt number will be reset. + +name: CI + +on: + push: + branches: [ "dev", "main" ] + pull_request: + branches: [ "dev", "main" ] + +env: + CI_BUILD_NUMBER_BASE: ${{ github.run_number }} + CI_TARGET_BRANCH: ${{ github.head_ref || github.ref_name }} + +jobs: + build: + + runs-on: windows-latest + + permissions: + contents: write + + steps: + - uses: actions/checkout@v4 + - name: Setup + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 9.0.x + - name: Compute build number + shell: bash + run: | + echo "CI_BUILD_NUMBER=$(($CI_BUILD_NUMBER_BASE+2300))" >> $GITHUB_ENV + - name: Build and Publish + env: + DOTNET_CLI_TELEMETRY_OPTOUT: true + NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + shell: pwsh + run: | + ./Build.ps1 diff --git a/Build.ps1 b/Build.ps1 index dc24499..e798284 100644 --- a/Build.ps1 +++ b/Build.ps1 @@ -1,49 +1,79 @@ -# This script originally (c) 2016 Serilog Contributors - license Apache 2.0 +Write-Output "build: Tool versions follow" -echo "build: Build started" +dotnet --version +dotnet --list-sdks + +Write-Output "build: Build started" Push-Location $PSScriptRoot +try { + if(Test-Path .\artifacts) { + Write-Output "build: Cleaning ./artifacts" + Remove-Item ./artifacts -Force -Recurse + } -if(Test-Path .\artifacts) { - echo "build: Cleaning .\artifacts" - Remove-Item .\artifacts -Force -Recurse -} + & dotnet restore --no-cache + + $dbp = [Xml] (Get-Content .\Directory.Version.props) + $versionPrefix = $dbp.Project.PropertyGroup.VersionPrefix -& dotnet restore --no-cache -if($LASTEXITCODE -ne 0) { exit 1 } + Write-Output "build: Package version prefix is $versionPrefix" -$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL]; -$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL]; -$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "main" -and $revision -ne "local"] + $branch = @{ $true = $env:CI_TARGET_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$NULL -ne $env:CI_TARGET_BRANCH]; + $revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:CI_BUILD_NUMBER, 10); $false = "local" }[$NULL -ne $env:CI_BUILD_NUMBER]; + $suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)) -replace '([^a-zA-Z0-9\-]*)', '')-$revision"}[$branch -eq "main" -and $revision -ne "local"] + $commitHash = $(git rev-parse --short HEAD) + $buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""] -echo "build: Version suffix is $suffix" + Write-Output "build: Package version suffix is $suffix" + Write-Output "build: Build version suffix is $buildSuffix" -foreach ($src in ls src/*) { - Push-Location $src + & dotnet build -c Release --version-suffix=$buildSuffix /p:ContinuousIntegrationBuild=true + if($LASTEXITCODE -ne 0) { throw "Build failed" } - echo "build: Packaging project in $src" + foreach ($src in Get-ChildItem src/*) { + Push-Location $src - if ($suffix) { - & dotnet publish -c Release -o ./obj/publish --version-suffix=$suffix - & dotnet pack -c Release -o ..\..\artifacts --no-build --version-suffix=$suffix - } else { - & dotnet publish -c Release -o ./obj/publish - & dotnet pack -c Release -o ..\..\artifacts --no-build + Write-Output "build: Packaging project in $src" + + if ($suffix) { + & dotnet pack -c Release --no-build --no-restore -o ../../artifacts --version-suffix=$suffix + } else { + & dotnet pack -c Release --no-build --no-restore -o ../../artifacts + } + if($LASTEXITCODE -ne 0) { throw "Packaging failed" } + + Pop-Location } - if($LASTEXITCODE -ne 0) { exit 1 } - Pop-Location -} + foreach ($test in Get-ChildItem test/*.Tests) { + Push-Location $test -foreach ($test in ls test/*.Tests) { - Push-Location $test + Write-Output "build: Testing project in $test" - echo "build: Testing project in $test" + & dotnet test -c Release --no-build --no-restore + if($LASTEXITCODE -ne 0) { throw "Testing failed" } - & dotnet test -c Release - if($LASTEXITCODE -ne 0) { exit 3 } + Pop-Location + } + + if ($env:NUGET_API_KEY) { + # GitHub Actions will only supply this to branch builds and not PRs. We publish + # builds from any branch this action targets (i.e. main and dev). + + Write-Output "build: Publishing NuGet packages" + + foreach ($nupkg in Get-ChildItem artifacts/*.nupkg) { + & dotnet nuget push -k $env:NUGET_API_KEY -s https://api.nuget.org/v3/index.json "$nupkg" + if($LASTEXITCODE -ne 0) { throw "Publishing failed" } + } + if (!($suffix)) { + Write-Output "build: Creating release for version $versionPrefix" + + iex "gh release create v$versionPrefix --title v$versionPrefix --generate-notes $(get-item ./artifacts/*.nupkg) $(get-item ./artifacts/*.snupkg)" + } + } +} finally { Pop-Location } - -Pop-Location diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 4db264c..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,23 +0,0 @@ -version: '{build}' -skip_tags: true -image: Visual Studio 2022 -install: -build_script: -- ps: ./Build.ps1 -test: off -artifacts: -- path: artifacts/Seq.Input.RabbitMQ.*.nupkg -deploy: -- provider: NuGet - api_key: - secure: HDcRadKRDne9Gd1vEQwZknRQz63ZbZMJh6e4sFmiXCpjkxC5WCoQ0ZecWBHtVulX - skip_symbols: true - on: - branch: /^(main|dev)$/ -- provider: GitHub - auth_token: - secure: hX+cZmW+9BCXy7vyH8myWsYdtQHyzzil9K5yvjJv7dK9XmyrGYYDj/DPzMqsXSjo - artifact: /Seq.Input.RabbitMQ.*\.nupkg/ - tag: v$(appveyor_build_version) - on: - branch: main From d194181d42c4ee3cb26daf0fc32175dba860f791 Mon Sep 17 00:00:00 2001 From: Ashley Mannix Date: Tue, 21 Jan 2025 10:39:41 +1000 Subject: [PATCH 26/36] try running CI on ubuntu --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d580450..b15d368 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ env: jobs: build: - runs-on: windows-latest + runs-on: ubuntu-latest permissions: contents: write From 15f43afc37853e38a4458ff79c690bf64e255c7e Mon Sep 17 00:00:00 2001 From: Ashley Mannix Date: Tue, 21 Jan 2025 10:44:17 +1000 Subject: [PATCH 27/36] add version props --- Directory.Version.props | 5 +++++ src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 Directory.Version.props diff --git a/Directory.Version.props b/Directory.Version.props new file mode 100644 index 0000000..e7bbeca --- /dev/null +++ b/Directory.Version.props @@ -0,0 +1,5 @@ + + + 1.0.0 + + diff --git a/src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj b/src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj index 133247d..136eb18 100644 --- a/src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj +++ b/src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj @@ -1,7 +1,6 @@ netstandard2.0 - 1.0.0 Ingest events into Seq directly from RabbitMQ Datalust and Contributors seq-app From 9158d6a3a419092d04310a9f3cfdf40ec9b2581f Mon Sep 17 00:00:00 2001 From: Ashley Mannix Date: Tue, 21 Jan 2025 10:48:51 +1000 Subject: [PATCH 28/36] remove stubbed test project --- seq-input-rabbitmq.sln | 4 ---- .../Seq.Input.RabbitMQ.Tests.csproj | 15 --------------- test/Seq.Input.RabbitMQ.Tests/UnitTest1.cs | 14 -------------- 3 files changed, 33 deletions(-) delete mode 100644 test/Seq.Input.RabbitMQ.Tests/Seq.Input.RabbitMQ.Tests.csproj delete mode 100644 test/Seq.Input.RabbitMQ.Tests/UnitTest1.cs diff --git a/seq-input-rabbitmq.sln b/seq-input-rabbitmq.sln index 18c6811..aa66fa0 100644 --- a/seq-input-rabbitmq.sln +++ b/seq-input-rabbitmq.sln @@ -12,12 +12,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sln", "sln", "{7D1D14F7-D40 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{704915B0-6D95-4CF8-ACC2-5ED939A2913C}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{BE42997A-5927-46E1-AFB5-C1D7A255212E}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Seq.Input.RabbitMQ", "src\Seq.Input.RabbitMQ\Seq.Input.RabbitMQ.csproj", "{E80E7949-A3AE-4C7C-9083-9FE9EE1F78E0}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Seq.Input.RabbitMQ.Tests", "test\Seq.Input.RabbitMQ.Tests\Seq.Input.RabbitMQ.Tests.csproj", "{9FF2C707-DD8D-4B9C-97A7-4E9F0D9D0008}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "example", "example", "{584683E5-0578-42F0-A958-3AAB3661AA9E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Demo", "example\Demo\Demo.csproj", "{99D4AAE3-35B3-4BE1-AA5F-7CC8E6B49A07}" diff --git a/test/Seq.Input.RabbitMQ.Tests/Seq.Input.RabbitMQ.Tests.csproj b/test/Seq.Input.RabbitMQ.Tests/Seq.Input.RabbitMQ.Tests.csproj deleted file mode 100644 index 4ec64e7..0000000 --- a/test/Seq.Input.RabbitMQ.Tests/Seq.Input.RabbitMQ.Tests.csproj +++ /dev/null @@ -1,15 +0,0 @@ - - - - netcoreapp2.1 - - false - - - - - - - - - diff --git a/test/Seq.Input.RabbitMQ.Tests/UnitTest1.cs b/test/Seq.Input.RabbitMQ.Tests/UnitTest1.cs deleted file mode 100644 index 1cac84f..0000000 --- a/test/Seq.Input.RabbitMQ.Tests/UnitTest1.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using Xunit; - -namespace Seq.Input.RabbitMQ.Tests -{ - public class UnitTest1 - { - [Fact] - public void Test1() - { - - } - } -} From 92b49fc12244a0aef991428fa5d72653c8935f03 Mon Sep 17 00:00:00 2001 From: Ashley Mannix Date: Tue, 21 Jan 2025 10:52:41 +1000 Subject: [PATCH 29/36] more project updates --- example/Demo/Demo.csproj | 2 +- seq-input-rabbitmq.sln | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/example/Demo/Demo.csproj b/example/Demo/Demo.csproj index 4686712..6f5ce49 100644 --- a/example/Demo/Demo.csproj +++ b/example/Demo/Demo.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1 + net9.0 Exe diff --git a/seq-input-rabbitmq.sln b/seq-input-rabbitmq.sln index aa66fa0..089c208 100644 --- a/seq-input-rabbitmq.sln +++ b/seq-input-rabbitmq.sln @@ -28,10 +28,6 @@ Global {E80E7949-A3AE-4C7C-9083-9FE9EE1F78E0}.Debug|Any CPU.Build.0 = Debug|Any CPU {E80E7949-A3AE-4C7C-9083-9FE9EE1F78E0}.Release|Any CPU.ActiveCfg = Release|Any CPU {E80E7949-A3AE-4C7C-9083-9FE9EE1F78E0}.Release|Any CPU.Build.0 = Release|Any CPU - {9FF2C707-DD8D-4B9C-97A7-4E9F0D9D0008}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9FF2C707-DD8D-4B9C-97A7-4E9F0D9D0008}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9FF2C707-DD8D-4B9C-97A7-4E9F0D9D0008}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9FF2C707-DD8D-4B9C-97A7-4E9F0D9D0008}.Release|Any CPU.Build.0 = Release|Any CPU {99D4AAE3-35B3-4BE1-AA5F-7CC8E6B49A07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {99D4AAE3-35B3-4BE1-AA5F-7CC8E6B49A07}.Debug|Any CPU.Build.0 = Debug|Any CPU {99D4AAE3-35B3-4BE1-AA5F-7CC8E6B49A07}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -42,7 +38,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {E80E7949-A3AE-4C7C-9083-9FE9EE1F78E0} = {704915B0-6D95-4CF8-ACC2-5ED939A2913C} - {9FF2C707-DD8D-4B9C-97A7-4E9F0D9D0008} = {BE42997A-5927-46E1-AFB5-C1D7A255212E} {99D4AAE3-35B3-4BE1-AA5F-7CC8E6B49A07} = {584683E5-0578-42F0-A958-3AAB3661AA9E} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution From 3969e43165978fe740cb17be82e99d80c312bb63 Mon Sep 17 00:00:00 2001 From: Ashley Mannix Date: Tue, 21 Jan 2025 10:54:27 +1000 Subject: [PATCH 30/36] make test running conditional --- Build.ps1 | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Build.ps1 b/Build.ps1 index e798284..5439920 100644 --- a/Build.ps1 +++ b/Build.ps1 @@ -46,15 +46,17 @@ try { Pop-Location } - foreach ($test in Get-ChildItem test/*.Tests) { - Push-Location $test + if(Test-Path .\test) { + foreach ($test in Get-ChildItem test/*.Tests) { + Push-Location $test - Write-Output "build: Testing project in $test" + Write-Output "build: Testing project in $test" - & dotnet test -c Release --no-build --no-restore - if($LASTEXITCODE -ne 0) { throw "Testing failed" } + & dotnet test -c Release --no-build --no-restore + if($LASTEXITCODE -ne 0) { throw "Testing failed" } - Pop-Location + Pop-Location + } } if ($env:NUGET_API_KEY) { From a61fb1fb02d12b093379ec7133e50d3632d7de7f Mon Sep 17 00:00:00 2001 From: Ashley Mannix Date: Tue, 21 Jan 2025 10:57:26 +1000 Subject: [PATCH 31/36] update build badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 34a1eb3..dab0623 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Seq.Input.RabbitMQ [![Build status](https://ci.appveyor.com/api/projects/status/lxab9qqdtqupk6y4?svg=true)](https://ci.appveyor.com/project/datalust/seq-input-rabbitmq) +# Seq.Input.RabbitMQ [![CI](https://github.com/datalust/seq-input-rabbitmq/actions/workflows/ci.yml/badge.svg)](https://github.com/datalust/seq-input-rabbitmq/actions/workflows/ci.yml) A Seq custom input that pulls events from RabbitMQ. **Requires Seq 5.1+.** From 6822068ac48b949bd0f656accda5a3e22f883881 Mon Sep 17 00:00:00 2001 From: Antonia Elek Date: Tue, 28 Jan 2025 11:46:32 +0100 Subject: [PATCH 32/36] Update src/Seq.Input.RabbitMQ/RabbitMQInput.cs Co-authored-by: Ashley Mannix --- src/Seq.Input.RabbitMQ/RabbitMQInput.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Seq.Input.RabbitMQ/RabbitMQInput.cs b/src/Seq.Input.RabbitMQ/RabbitMQInput.cs index 253e408..c3e6ea0 100644 --- a/src/Seq.Input.RabbitMQ/RabbitMQInput.cs +++ b/src/Seq.Input.RabbitMQ/RabbitMQInput.cs @@ -83,7 +83,7 @@ public class RabbitMQInput : SeqApp, IPublishJson, IDisposable [SeqAppSetting( DisplayName = "Dead Letter Exchange", IsOptional = true, - HelpText = "Name of dead letter exchange associated with this queue.")] + HelpText = "The name of the dead letter exchange associated with this queue. If specified, the exchange will be used when declaring the queue, otherwise no dead lettering will be configured.")] public string Dlx { get; set; } = "guest"; public void Start(TextWriter inputWriter) From ca6425bef3914566636bcb30930b056323cbcd1b Mon Sep 17 00:00:00 2001 From: Antonia Elek Date: Thu, 30 Jan 2025 16:41:08 +0100 Subject: [PATCH 33/36] Remove default value for Dlx parameter. --- src/Seq.Input.RabbitMQ/RabbitMQInput.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Seq.Input.RabbitMQ/RabbitMQInput.cs b/src/Seq.Input.RabbitMQ/RabbitMQInput.cs index c3e6ea0..cd41e8f 100644 --- a/src/Seq.Input.RabbitMQ/RabbitMQInput.cs +++ b/src/Seq.Input.RabbitMQ/RabbitMQInput.cs @@ -84,7 +84,7 @@ public class RabbitMQInput : SeqApp, IPublishJson, IDisposable DisplayName = "Dead Letter Exchange", IsOptional = true, HelpText = "The name of the dead letter exchange associated with this queue. If specified, the exchange will be used when declaring the queue, otherwise no dead lettering will be configured.")] - public string Dlx { get; set; } = "guest"; + public string Dlx { get; set; } public void Start(TextWriter inputWriter) { From b3fcf6e38d66b2b5e262aa81b7ef3f9d877df340 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Mon, 10 Nov 2025 15:07:11 +1000 Subject: [PATCH 34/36] Update to RabbitMQ.Client 7, lift other dependency versions --- README.md | 2 +- example/Demo/Program.cs | 42 ++- seq-input-rabbitmq.sln.DotSettings | 2 + src/Seq.Input.RabbitMQ/RabbitMQInput.cs | 243 +++++++++--------- src/Seq.Input.RabbitMQ/RabbitMQListener.cs | 110 ++++---- .../Seq.Input.RabbitMQ.csproj | 7 +- 6 files changed, 203 insertions(+), 203 deletions(-) create mode 100644 seq-input-rabbitmq.sln.DotSettings diff --git a/README.md b/README.md index dab0623..37c5bff 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Seq.Input.RabbitMQ [![CI](https://github.com/datalust/seq-input-rabbitmq/actions/workflows/ci.yml/badge.svg)](https://github.com/datalust/seq-input-rabbitmq/actions/workflows/ci.yml) -A Seq custom input that pulls events from RabbitMQ. **Requires Seq 5.1+.** +A Seq custom input that pulls events from RabbitMQ. **Requires Seq 2025.2+.** ### Getting started diff --git a/example/Demo/Program.cs b/example/Demo/Program.cs index 280d691..84acd4f 100644 --- a/example/Demo/Program.cs +++ b/example/Demo/Program.cs @@ -1,34 +1,24 @@ -using System; -using System.Threading; +using System.Threading; using Serilog; using Serilog.Formatting.Compact; using Serilog.Sinks.RabbitMQ.Sinks.RabbitMQ; -namespace Demo +var rmq = new RabbitMQConfiguration { - public class Program - { - public static void Main() - { - var rmq = new RabbitMQConfiguration - { - Hostname = "localhost", - Username = "guest", - Password = "guest", - Exchange = "", - RouteKey = "logs" - }; + Hostname = "localhost", + Username = "guest", + Password = "guest", + Exchange = "", + RouteKey = "logs" +}; - Log.Logger = new LoggerConfiguration() - .Enrich.WithProperty("Application", "Demo") - .WriteTo.RabbitMQ(rmq, new CompactJsonFormatter()) - .CreateLogger(); +Log.Logger = new LoggerConfiguration() + .Enrich.WithProperty("Application", "Demo") + .WriteTo.RabbitMQ(rmq, new CompactJsonFormatter()) + .CreateLogger(); - while (true) - { - Log.Information("Yo, RabbitMQ!"); - Thread.Sleep(1000); - } - } - } +while (true) +{ + Log.Information("Yo, RabbitMQ!"); + Thread.Sleep(1000); } diff --git a/seq-input-rabbitmq.sln.DotSettings b/seq-input-rabbitmq.sln.DotSettings new file mode 100644 index 0000000..3809fdb --- /dev/null +++ b/seq-input-rabbitmq.sln.DotSettings @@ -0,0 +1,2 @@ + + MQV \ No newline at end of file diff --git a/src/Seq.Input.RabbitMQ/RabbitMQInput.cs b/src/Seq.Input.RabbitMQ/RabbitMQInput.cs index cd41e8f..14079f2 100644 --- a/src/Seq.Input.RabbitMQ/RabbitMQInput.cs +++ b/src/Seq.Input.RabbitMQ/RabbitMQInput.cs @@ -1,134 +1,141 @@ using System; using System.IO; using System.Text; +using System.Threading.Tasks; using Seq.Apps; +// ReSharper disable MemberCanBePrivate.Global, UnusedType.Global, UnusedAutoPropertyAccessor.Global -namespace Seq.Input.RabbitMQ +namespace Seq.Input.RabbitMQ; + +[SeqApp("RabbitMQ Input", + Description = "Pulls JSON-formatted events from a RabbitMQ queue. For details of the " + + "supported JSON schema, see " + + "https://github.com/serilog/serilog-formatting-compact/#format-details.")] +public sealed class RabbitMQInput : SeqApp, IPublishJson, IDisposable { - [SeqApp("RabbitMQ Input", - Description = "Pulls JSON-formatted events from a RabbitMQ queue. For details of the " + - "supported JSON schema, see " + - "https://github.com/serilog/serilog-formatting-compact/#format-details.")] - public class RabbitMQInput : SeqApp, IPublishJson, IDisposable + RabbitMQListener _listener; + + [SeqAppSetting( + DisplayName = "RabbitMQ host", + IsOptional = true, + HelpText = "The hostname on which RabbitMQ is running. The default is `localhost`.")] + public string RabbitMQHost { get; set; } = "localhost"; + + [SeqAppSetting( + DisplayName = "RabbitMQ Virtual Host", + IsOptional = true, + HelpText = "The virtual host in RabbitMQ. The default is `/`.")] + public string RabbitMQVHost { get; set; } = "/"; + + [SeqAppSetting( + DisplayName = "RabbitMQ port", + IsOptional = true, + HelpText = "The port on which the RabbitMQ server is listening. The default is `5672`.")] + public int RabbitMQPort { get; set; } = 5672; + + [SeqAppSetting( + DisplayName = "RabbitMQ user", + IsOptional = true, + HelpText = "The username provided when connecting to RabbitMQ. The default is `guest`.")] + public string RabbitMQUser { get; set; } = "guest"; + + [SeqAppSetting( + DisplayName = "RabbitMQ password", + IsOptional = true, + InputType = SettingInputType.Password, + HelpText = "The password provided when connecting to RabbitMQ. The default is `guest`.")] + public string RabbitMQPassword { get; set; } = "guest"; + + [SeqAppSetting( + DisplayName = "RabbitMQ queue", + IsOptional = true, + HelpText = "The RabbitMQ queue name to receive events from. The default is `Logs`.")] + public string RabbitMQQueue { get; set; } = "logs"; + + [SeqAppSetting( + DisplayName = "Require SSL", + IsOptional = true, + HelpText = "Whether or not the connection is with SSL. The default is false.")] + public bool IsSsl { get; set; } + + [SeqAppSetting( + DisplayName = "Durable", + IsOptional = true, + HelpText = "Whether or not the queue is durable. The default is false.")] + public bool IsQueueDurable { get; set; } + + [SeqAppSetting( + DisplayName = "Exclusive", + IsOptional = true, + HelpText = "Whether or not the queue is exclusive. The default is false.")] + public bool IsQueueExclusive { get; set; } + + [SeqAppSetting( + DisplayName = "Auto-delete", + IsOptional = true, + HelpText = "Whether or not the queue subscription is durable. The default is false.")] + public bool IsQueueAutoDelete { get; set; } + + [SeqAppSetting( + DisplayName = "Auto-ACK", + IsOptional = true, + HelpText = "Whether or not messages should be auto-acknowledged. The default is true.")] + public bool IsReceiveAutoAck { get; set; } = true; + + [SeqAppSetting( + DisplayName = "Dead Letter Exchange", + IsOptional = true, + HelpText = "The name of the dead letter exchange associated with this queue. If specified, the exchange will be used when declaring the queue, otherwise no dead lettering will be configured.")] + public string Dlx { get; set; } + + public void Start(TextWriter inputWriter) { - RabbitMQListener _listener; - - [SeqAppSetting( - DisplayName = "RabbitMQ host", - IsOptional = true, - HelpText = "The hostname on which RabbitMQ is running. The default is `localhost`.")] - public string RabbitMQHost { get; set; } = "localhost"; - - [SeqAppSetting( - DisplayName = "RabbitMQ Virtual Host", - IsOptional = true, - HelpText = "The virtual host in RabbitMQ. The default is `/`.")] - public string RabbitMQVHost { get; set; } = "/"; - - [SeqAppSetting( - DisplayName = "RabbitMQ port", - IsOptional = true, - HelpText = "The port on which the RabbitMQ server is listening. The default is `5672`.")] - public int RabbitMQPort { get; set; } = 5672; - - [SeqAppSetting( - DisplayName = "RabbitMQ user", - IsOptional = true, - HelpText = "The username provided when connecting to RabbitMQ. The default is `guest`.")] - public string RabbitMQUser { get; set; } = "guest"; - - [SeqAppSetting( - DisplayName = "RabbitMQ password", - IsOptional = true, - InputType = SettingInputType.Password, - HelpText = "The password provided when connecting to RabbitMQ. The default is `guest`.")] - public string RabbitMQPassword { get; set; } = "guest"; - - [SeqAppSetting( - DisplayName = "RabbitMQ queue", - IsOptional = true, - HelpText = "The RabbitMQ queue name to receive events from. The default is `Logs`.")] - public string RabbitMQQueue { get; set; } = "logs"; - - [SeqAppSetting( - DisplayName = "Require SSL", - IsOptional = true, - HelpText = "Whether or not the connection is with SSL. The default is false.")] - public bool IsSsl { get; set; } - - [SeqAppSetting( - DisplayName = "Durable", - IsOptional = true, - HelpText = "Whether or not the queue is durable. The default is false.")] - public bool IsQueueDurable { get; set; } - - [SeqAppSetting( - DisplayName = "Exclusive", - IsOptional = true, - HelpText = "Whether or not the queue is exclusive. The default is false.")] - public bool IsQueueExclusive { get; set; } - - [SeqAppSetting( - DisplayName = "Auto-delete", - IsOptional = true, - HelpText = "Whether or not the queue subscription is durable. The default is false.")] - public bool IsQueueAutoDelete { get; set; } - - [SeqAppSetting( - DisplayName = "Auto-ACK", - IsOptional = true, - HelpText = "Whether or not messages should be auto-acknowledged. The default is true.")] - public bool IsReceiveAutoAck { get; set; } = true; - - [SeqAppSetting( - DisplayName = "Dead Letter Exchange", - IsOptional = true, - HelpText = "The name of the dead letter exchange associated with this queue. If specified, the exchange will be used when declaring the queue, otherwise no dead lettering will be configured.")] - public string Dlx { get; set; } - - public void Start(TextWriter inputWriter) + var sync = new object(); + Task ReceiveAsync(ReadOnlyMemory body) { - var sync = new object(); - void Receive(ReadOnlyMemory body) + try { - try - { - lock (sync) - { - var clef = Encoding.UTF8.GetString(body.ToArray()); - inputWriter.WriteLine(clef); - } - } - catch (Exception ex) + lock (sync) { - Log.Error(ex, "A received message could not be decoded"); + var clef = Encoding.UTF8.GetString(body.ToArray()); + inputWriter.WriteLine(clef); } } - - _listener = new RabbitMQListener( - Receive, - RabbitMQHost, - RabbitMQVHost, - RabbitMQPort, - RabbitMQUser, - RabbitMQPassword, - RabbitMQQueue, - IsSsl, - IsQueueDurable, - IsQueueAutoDelete, - IsQueueExclusive, - IsReceiveAutoAck, - Dlx); + catch (Exception ex) + { + Log.Error(ex, "A received message could not be decoded"); + } + + return Task.CompletedTask; } - public void Stop() - { - _listener.Close(); - } + // Not a deadlock risk on .NET 8, but ideally we'll introduce `IPublishJsonAsync` and provide + // async start/stop/dispose variants. + _listener = RabbitMQListener.CreateAsync( + ReceiveAsync, + RabbitMQHost, + RabbitMQVHost, + RabbitMQPort, + RabbitMQUser, + RabbitMQPassword, + RabbitMQQueue, + IsSsl, + IsQueueDurable, + IsQueueAutoDelete, + IsQueueExclusive, + IsReceiveAutoAck, + Dlx).Result; + } - public void Dispose() - { - _listener?.Dispose(); - } + public void Stop() + { + // Not a deadlock risk on .NET 8, but ideally we'll introduce `IPublishJsonAsync` and provide + // async start/stop/dispose variants. + _listener.CloseAsync().Wait(); + } + + public void Dispose() + { + _listener?.Dispose(); } -} +} \ No newline at end of file diff --git a/src/Seq.Input.RabbitMQ/RabbitMQListener.cs b/src/Seq.Input.RabbitMQ/RabbitMQListener.cs index 1006e66..3a9274d 100644 --- a/src/Seq.Input.RabbitMQ/RabbitMQListener.cs +++ b/src/Seq.Input.RabbitMQ/RabbitMQListener.cs @@ -1,71 +1,71 @@ using System; using System.Collections.Generic; -using System.Net.Security; +using System.Threading.Tasks; using RabbitMQ.Client; using RabbitMQ.Client.Events; -namespace Seq.Input.RabbitMQ +namespace Seq.Input.RabbitMQ; + +class RabbitMQListener(IConnection connection, IChannel channel) : IDisposable { - class RabbitMQListener : IDisposable + public static async Task CreateAsync( + Func, Task> receiveAsync, + string rabbitMQHost, + string rabbitMQVHost, + int rabbitMQPort, + string rabbitMQUser, + string rabbitMQPassword, + string rabbitMQQueue, + bool isSsl, + bool isQueueDurable, + bool isQueueAutoDelete, + bool isQueueExclusive, + bool isReceiveAutoAck, + string dlx) { - readonly IConnection _connection; - readonly IModel _channel; - - public RabbitMQListener(Action> receive, - string rabbitMQHost, - string rabbitMQVHost, - int rabbitMQPort, - string rabbitMQUser, - string rabbitMQPassword, - string rabbitMQQueue, - bool isSsl, - bool isQueueDurable, - bool isQueueAutoDelete, - bool isQueueExclusive, - bool isReceiveAutoAck, - string dlx) + var factory = new ConnectionFactory { - var factory = new ConnectionFactory + HostName = rabbitMQHost, + VirtualHost = rabbitMQVHost, + Port = rabbitMQPort, + UserName = rabbitMQUser, + Password = rabbitMQPassword, + Ssl = { - HostName = rabbitMQHost, - VirtualHost = rabbitMQVHost, - Port = rabbitMQPort, - UserName = rabbitMQUser, - Password = rabbitMQPassword, - Ssl = - { - Enabled = isSsl - } - }; + Enabled = isSsl + } + }; - _connection = factory.CreateConnection(); - _channel = _connection.CreateModel(); + var connection = await factory.CreateConnectionAsync(); + var channel = await connection.CreateChannelAsync(); - var arguments = string.IsNullOrWhiteSpace(dlx) - ? null - : new Dictionary { {"x-dead-letter-exchange", dlx} }; + var arguments = string.IsNullOrWhiteSpace(dlx) + ? null + : new Dictionary { {"x-dead-letter-exchange", dlx} }; - _channel.QueueDeclare( - rabbitMQQueue, - durable: isQueueDurable, - exclusive: isQueueExclusive, - autoDelete: isQueueAutoDelete, - arguments: arguments); + await channel.QueueDeclareAsync( + rabbitMQQueue, + durable: isQueueDurable, + exclusive: isQueueExclusive, + autoDelete: isQueueAutoDelete, + arguments: arguments); - var consumer = new EventingBasicConsumer(_channel); - consumer.Received += (model, ea) => receive(ea.Body); - _channel.BasicConsume(rabbitMQQueue, autoAck: isReceiveAutoAck, consumer: consumer); - } + var consumer = new AsyncEventingBasicConsumer(channel); + consumer.ReceivedAsync += async (_, ea) => await receiveAsync(ea.Body); + await channel.BasicConsumeAsync(rabbitMQQueue, autoAck: isReceiveAutoAck, consumer: consumer); - public void Close() - { - _channel.Close(); - } + return new RabbitMQListener(connection, channel); + } - public void Dispose() - { - _channel?.Dispose(); - _connection?.Close(); - } + public async Task CloseAsync() + { + await channel.CloseAsync(); + await connection.CloseAsync(); + } + + public void Dispose() + { + channel?.Dispose(); + connection?.Dispose(); } -} +} \ No newline at end of file diff --git a/src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj b/src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj index 136eb18..62cdd64 100644 --- a/src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj +++ b/src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj @@ -1,6 +1,7 @@ - netstandard2.0 + net8.0 + latest Ingest events into Seq directly from RabbitMQ Datalust and Contributors seq-app @@ -13,8 +14,8 @@ - - + + From e6843e47687faa58a652a6cc50b2544db652ac22 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Mon, 10 Nov 2025 15:21:18 +1000 Subject: [PATCH 35/36] Update demo client --- example/Demo/Demo.csproj | 6 +++--- example/Demo/Program.cs | 20 +++++++++----------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/example/Demo/Demo.csproj b/example/Demo/Demo.csproj index 6f5ce49..90b3739 100644 --- a/example/Demo/Demo.csproj +++ b/example/Demo/Demo.csproj @@ -6,9 +6,9 @@ - - - + + + diff --git a/example/Demo/Program.cs b/example/Demo/Program.cs index 84acd4f..e2d9bb0 100644 --- a/example/Demo/Program.cs +++ b/example/Demo/Program.cs @@ -1,20 +1,18 @@ using System.Threading; using Serilog; using Serilog.Formatting.Compact; -using Serilog.Sinks.RabbitMQ.Sinks.RabbitMQ; - -var rmq = new RabbitMQConfiguration -{ - Hostname = "localhost", - Username = "guest", - Password = "guest", - Exchange = "", - RouteKey = "logs" -}; Log.Logger = new LoggerConfiguration() .Enrich.WithProperty("Application", "Demo") - .WriteTo.RabbitMQ(rmq, new CompactJsonFormatter()) + .WriteTo.RabbitMQ((client, sink) => + { + client.Hostnames.Add("localhost"); + client.Username = "guest"; + client.Password = "guest"; + client.Exchange = ""; + client.RoutingKey = "logs"; + sink.TextFormatter = new CompactJsonFormatter(); + }) .CreateLogger(); while (true) From 66468a21d2f6192a65bd0ced52adb456ef1fade8 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Tue, 11 Nov 2025 10:07:37 +1000 Subject: [PATCH 36/36] Fix packaging regression caused by earlier build script migration --- Build.ps1 | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Build.ps1 b/Build.ps1 index 5439920..7952809 100644 --- a/Build.ps1 +++ b/Build.ps1 @@ -28,18 +28,17 @@ try { Write-Output "build: Package version suffix is $suffix" Write-Output "build: Build version suffix is $buildSuffix" - & dotnet build -c Release --version-suffix=$buildSuffix /p:ContinuousIntegrationBuild=true - if($LASTEXITCODE -ne 0) { throw "Build failed" } - foreach ($src in Get-ChildItem src/*) { Push-Location $src Write-Output "build: Packaging project in $src" if ($suffix) { - & dotnet pack -c Release --no-build --no-restore -o ../../artifacts --version-suffix=$suffix + & dotnet publish -c Release -o ./obj/publish --version-suffix=$buildSuffix /p:ContinuousIntegrationBuild=true + & dotnet pack -c Release -o ../../artifacts --no-build --version-suffix=$suffix } else { - & dotnet pack -c Release --no-build --no-restore -o ../../artifacts + & dotnet publish -c Release -o ./obj/publish /p:ContinuousIntegrationBuild=true + & dotnet pack -c Release -o ../../artifacts --no-build } if($LASTEXITCODE -ne 0) { throw "Packaging failed" }