diff --git a/.gitignore b/.gitignore index ca5680d5108..1005e6865bb 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,8 @@ binaries *.lock.json .nu .learningtransport +.db +.logs _UpgradeReport.* *.cache *~ diff --git a/samples/generated-samples-supporting-netcore.include.md b/samples/generated-samples-supporting-netcore.include.md index 5deca452de2..3e600d93822 100644 --- a/samples/generated-samples-supporting-netcore.include.md +++ b/samples/generated-samples-supporting-netcore.include.md @@ -67,6 +67,7 @@ * [Monitor Azure Storage Queues endpoints with ServiceControl adapter](/samples/servicecontrol/adapter-asq-multi-storage-account/?version=sctransportadapter_2) * [Monitor RabbitMQ direct routing topology with ServiceControl adapter](/samples/servicecontrol/adapter-rabbitmq-different-topologies/?version=sctransportadapter_2) * [Monitor third-party systems with custom checks](/samples/servicecontrol/monitoring3rdparty/?version=customchecks_3) +* [Monitor with ServiceControl events](/samples/servicecontrol/events-subscription/?version=servicecontrolcontracts_1) * [Multiple Deserializers](/samples/serializers/multiple-deserializers/?version=core_7) * [Native integration](/samples/sqltransport/native-integration/?version=sqltransport_4) * [Native integration with RabbitMQ](/samples/rabbitmq/native-integration/?version=rabbit_5) diff --git a/samples/servicecontrol/events-subscription/ServiceControlContracts_1/EndpointsMonitor/CustomEventsHandler.cs b/samples/servicecontrol/events-subscription/ServiceControlContracts_1/EndpointsMonitor/CustomEventsHandler.cs index 74908582804..ea0fcb1ed87 100644 --- a/samples/servicecontrol/events-subscription/ServiceControlContracts_1/EndpointsMonitor/CustomEventsHandler.cs +++ b/samples/servicecontrol/events-subscription/ServiceControlContracts_1/EndpointsMonitor/CustomEventsHandler.cs @@ -14,19 +14,19 @@ public class CustomEventsHandler : public Task Handle(MessageFailed message, IMessageHandlerContext context) { - log.Error("Received ServiceControl 'MessageFailed' event for a SimpleMessage."); + log.Error($"Received ServiceControl 'MessageFailed' event for a {message.MessageType} with ID {message.FailedMessageId}."); return Task.CompletedTask; } public Task Handle(HeartbeatStopped message, IMessageHandlerContext context) { - log.Warn($"Heartbeat from {message.EndpointName} stopped."); + log.Warn($"Heartbeats from {message.EndpointName} have stopped."); return Task.CompletedTask; } public Task Handle(HeartbeatRestored message, IMessageHandlerContext context) { - log.Info($"Heartbeat from {message.EndpointName} restored."); + log.Info($"Heartbeats from {message.EndpointName} have been restored."); return Task.CompletedTask; } } diff --git a/samples/servicecontrol/events-subscription/ServiceControlContracts_1/EndpointsMonitor/EndpointsMonitor.Core.csproj b/samples/servicecontrol/events-subscription/ServiceControlContracts_1/EndpointsMonitor/EndpointsMonitor.Core.csproj new file mode 100644 index 00000000000..592d1049421 --- /dev/null +++ b/samples/servicecontrol/events-subscription/ServiceControlContracts_1/EndpointsMonitor/EndpointsMonitor.Core.csproj @@ -0,0 +1,13 @@ + + + netcoreapp2.1 + Exe + 7.1 + + + + + + + + \ No newline at end of file diff --git a/samples/servicecontrol/events-subscription/ServiceControlContracts_1/EndpointsMonitor/EndpointsMonitor.csproj b/samples/servicecontrol/events-subscription/ServiceControlContracts_1/EndpointsMonitor/EndpointsMonitor.csproj index 610bd3e2543..11ada9a3f8b 100644 --- a/samples/servicecontrol/events-subscription/ServiceControlContracts_1/EndpointsMonitor/EndpointsMonitor.csproj +++ b/samples/servicecontrol/events-subscription/ServiceControlContracts_1/EndpointsMonitor/EndpointsMonitor.csproj @@ -8,7 +8,6 @@ - \ No newline at end of file diff --git a/samples/servicecontrol/events-subscription/ServiceControlContracts_1/EndpointsMonitor/Program.cs b/samples/servicecontrol/events-subscription/ServiceControlContracts_1/EndpointsMonitor/Program.cs index c31b3e03a98..f9e63f5c951 100644 --- a/samples/servicecontrol/events-subscription/ServiceControlContracts_1/EndpointsMonitor/Program.cs +++ b/samples/servicecontrol/events-subscription/ServiceControlContracts_1/EndpointsMonitor/Program.cs @@ -13,12 +13,7 @@ static async Task Main() endpointConfiguration.UsePersistence(); endpointConfiguration.SendFailedMessagesTo("error"); - var transport = endpointConfiguration.UseTransport(); - var routing = transport.Routing(); - routing.RegisterPublisher( - typeof(ServiceControl.Contracts.MessageFailed).Assembly, - "Particular.ServiceControl" - ); + var transport = endpointConfiguration.UseTransport(); var conventions = endpointConfiguration.Conventions(); conventions.DefiningEventsAs( diff --git a/samples/servicecontrol/events-subscription/ServiceControlContracts_1/EndpointsMonitoring.Core.sln b/samples/servicecontrol/events-subscription/ServiceControlContracts_1/EndpointsMonitoring.Core.sln new file mode 100644 index 00000000000..87c5df2f3cd --- /dev/null +++ b/samples/servicecontrol/events-subscription/ServiceControlContracts_1/EndpointsMonitoring.Core.sln @@ -0,0 +1,30 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26730.12 +MinimumVisualStudioVersion = 15.0.26730.12 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EndpointsMonitor.Core", "EndpointsMonitor\EndpointsMonitor.Core.csproj", "{A8963C7C-F1F1-4DA9-8FCA-BE5B59CD88A1}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NServiceBusEndpoint.Core", "NServiceBusEndpoint\NServiceBusEndpoint.Core.csproj", "{72518D27-BBFF-482E-8102-7C64BA828238}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlatformLauncher.Core", "PlatformLauncher\PlatformLauncher.Core.csproj", "{A173C333-91F6-4D87-8FF6-E960B4C84450}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A8963C7C-F1F1-4DA9-8FCA-BE5B59CD88A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A8963C7C-F1F1-4DA9-8FCA-BE5B59CD88A1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {72518D27-BBFF-482E-8102-7C64BA828238}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {72518D27-BBFF-482E-8102-7C64BA828238}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A173C333-91F6-4D87-8FF6-E960B4C84450}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A173C333-91F6-4D87-8FF6-E960B4C84450}.Debug|Any CPU.Build.0 = Debug|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {27A88F91-DC83-4374-A818-BB89E8287243} + EndGlobalSection +EndGlobal diff --git a/samples/servicecontrol/events-subscription/ServiceControlContracts_1/EndpointsMonitoring.Core.sln.DotSettings b/samples/servicecontrol/events-subscription/ServiceControlContracts_1/EndpointsMonitoring.Core.sln.DotSettings new file mode 100644 index 00000000000..7926067e7dc --- /dev/null +++ b/samples/servicecontrol/events-subscription/ServiceControlContracts_1/EndpointsMonitoring.Core.sln.DotSettings @@ -0,0 +1,6 @@ + + ..\..\..\..\..\tools\Shared.DotSettings + True + True + 1 + \ No newline at end of file diff --git a/samples/servicecontrol/events-subscription/ServiceControlContracts_1/EndpointsMonitoring.StartupProjects.txt b/samples/servicecontrol/events-subscription/ServiceControlContracts_1/EndpointsMonitoring.StartupProjects.txt index da5140f157f..a1aa7787229 100644 --- a/samples/servicecontrol/events-subscription/ServiceControlContracts_1/EndpointsMonitoring.StartupProjects.txt +++ b/samples/servicecontrol/events-subscription/ServiceControlContracts_1/EndpointsMonitoring.StartupProjects.txt @@ -1,2 +1,3 @@ EndpointsMonitor\EndpointsMonitor.csproj -NServiceBusEndpoint\NServiceBusEndpoint.csproj \ No newline at end of file +NServiceBusEndpoint\NServiceBusEndpoint.csproj +PlatformLauncher\PlatformLauncher.csproj \ No newline at end of file diff --git a/samples/servicecontrol/events-subscription/ServiceControlContracts_1/EndpointsMonitoring.sln b/samples/servicecontrol/events-subscription/ServiceControlContracts_1/EndpointsMonitoring.sln index 6440e31aba4..d3beab78c0c 100644 --- a/samples/servicecontrol/events-subscription/ServiceControlContracts_1/EndpointsMonitoring.sln +++ b/samples/servicecontrol/events-subscription/ServiceControlContracts_1/EndpointsMonitoring.sln @@ -1,11 +1,12 @@ - Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.26730.12 MinimumVisualStudioVersion = 15.0.26730.12 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NServiceBusEndpoint", "NServiceBusEndpoint\NServiceBusEndpoint.csproj", "{814CEA2E-C5F5-4315-8FC3-8517B09C5931}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NServiceBusEndpoint", "NServiceBusEndpoint\NServiceBusEndpoint.csproj", "{814CEA2E-C5F5-4315-8FC3-8517B09C5931}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EndpointsMonitor", "EndpointsMonitor\EndpointsMonitor.csproj", "{7A1C1662-35D1-4720-9F9F-4D23E9A57CE1}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EndpointsMonitor", "EndpointsMonitor\EndpointsMonitor.csproj", "{7A1C1662-35D1-4720-9F9F-4D23E9A57CE1}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlatformLauncher", "PlatformLauncher\PlatformLauncher.csproj", "{EED01887-FC83-4920-901E-2B52AFFDCBE6}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -16,8 +17,13 @@ Global {814CEA2E-C5F5-4315-8FC3-8517B09C5931}.Debug|Any CPU.Build.0 = Debug|Any CPU {7A1C1662-35D1-4720-9F9F-4D23E9A57CE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {7A1C1662-35D1-4720-9F9F-4D23E9A57CE1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EED01887-FC83-4920-901E-2B52AFFDCBE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EED01887-FC83-4920-901E-2B52AFFDCBE6}.Debug|Any CPU.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {E4ACEBE4-E83E-4146-9EFF-9E61728BD574} + EndGlobalSection EndGlobal diff --git a/samples/servicecontrol/events-subscription/ServiceControlContracts_1/EndpointsMonitoringCore..sln.DotSettings b/samples/servicecontrol/events-subscription/ServiceControlContracts_1/EndpointsMonitoringCore..sln.DotSettings new file mode 100644 index 00000000000..7926067e7dc --- /dev/null +++ b/samples/servicecontrol/events-subscription/ServiceControlContracts_1/EndpointsMonitoringCore..sln.DotSettings @@ -0,0 +1,6 @@ + + ..\..\..\..\..\tools\Shared.DotSettings + True + True + 1 + \ No newline at end of file diff --git a/samples/servicecontrol/events-subscription/ServiceControlContracts_1/NServiceBusEndpoint/NServiceBusEndpoint.Core.csproj b/samples/servicecontrol/events-subscription/ServiceControlContracts_1/NServiceBusEndpoint/NServiceBusEndpoint.Core.csproj new file mode 100644 index 00000000000..8642d181f54 --- /dev/null +++ b/samples/servicecontrol/events-subscription/ServiceControlContracts_1/NServiceBusEndpoint/NServiceBusEndpoint.Core.csproj @@ -0,0 +1,13 @@ + + + netcoreapp2.1 + Exe + 7.1 + + + + + + + + \ No newline at end of file diff --git a/samples/servicecontrol/events-subscription/ServiceControlContracts_1/NServiceBusEndpoint/NServiceBusEndpoint.csproj b/samples/servicecontrol/events-subscription/ServiceControlContracts_1/NServiceBusEndpoint/NServiceBusEndpoint.csproj index e9b80bd3432..21feecc811c 100644 --- a/samples/servicecontrol/events-subscription/ServiceControlContracts_1/NServiceBusEndpoint/NServiceBusEndpoint.csproj +++ b/samples/servicecontrol/events-subscription/ServiceControlContracts_1/NServiceBusEndpoint/NServiceBusEndpoint.csproj @@ -9,6 +9,5 @@ - \ No newline at end of file diff --git a/samples/servicecontrol/events-subscription/ServiceControlContracts_1/NServiceBusEndpoint/Program.cs b/samples/servicecontrol/events-subscription/ServiceControlContracts_1/NServiceBusEndpoint/Program.cs index 8625f3c4038..964e663c282 100644 --- a/samples/servicecontrol/events-subscription/ServiceControlContracts_1/NServiceBusEndpoint/Program.cs +++ b/samples/servicecontrol/events-subscription/ServiceControlContracts_1/NServiceBusEndpoint/Program.cs @@ -8,10 +8,9 @@ static async Task Main() { Console.Title = "NServiceBusEndpoint"; var endpointConfiguration = new EndpointConfiguration("NServiceBusEndpoint"); - endpointConfiguration.UseTransport(); + endpointConfiguration.UseTransport(); endpointConfiguration.UseSerialization(); endpointConfiguration.EnableInstallers(); - endpointConfiguration.UsePersistence(); endpointConfiguration.SendFailedMessagesTo("error"); #region DisableRetries diff --git a/samples/servicecontrol/events-subscription/ServiceControlContracts_1/PlatformLauncher/PlatformLauncher.Core.csproj b/samples/servicecontrol/events-subscription/ServiceControlContracts_1/PlatformLauncher/PlatformLauncher.Core.csproj new file mode 100644 index 00000000000..2cd030ef38c --- /dev/null +++ b/samples/servicecontrol/events-subscription/ServiceControlContracts_1/PlatformLauncher/PlatformLauncher.Core.csproj @@ -0,0 +1,10 @@ + + + Exe + netcoreapp2.1 + 7.1 + + + + + \ No newline at end of file diff --git a/samples/servicecontrol/events-subscription/ServiceControlContracts_1/PlatformLauncher/PlatformLauncher.csproj b/samples/servicecontrol/events-subscription/ServiceControlContracts_1/PlatformLauncher/PlatformLauncher.csproj new file mode 100644 index 00000000000..39dace690ee --- /dev/null +++ b/samples/servicecontrol/events-subscription/ServiceControlContracts_1/PlatformLauncher/PlatformLauncher.csproj @@ -0,0 +1,10 @@ + + + Exe + net461 + 7.1 + + + + + \ No newline at end of file diff --git a/samples/servicecontrol/events-subscription/ServiceControlContracts_1/PlatformLauncher/Program.cs b/samples/servicecontrol/events-subscription/ServiceControlContracts_1/PlatformLauncher/Program.cs new file mode 100644 index 00000000000..2501b019cc6 --- /dev/null +++ b/samples/servicecontrol/events-subscription/ServiceControlContracts_1/PlatformLauncher/Program.cs @@ -0,0 +1,13 @@ +namespace PlatformLauncher +{ + using System; + + class Program + { + static void Main(string[] args) + { + Console.Title = "PlatformLauncher"; + Particular.PlatformLauncher.Launch(); + } + } +} diff --git a/samples/servicecontrol/events-subscription/sample.md b/samples/servicecontrol/events-subscription/sample.md index 74ab2d27ddc..b0353420aa0 100644 --- a/samples/servicecontrol/events-subscription/sample.md +++ b/samples/servicecontrol/events-subscription/sample.md @@ -12,20 +12,21 @@ related: - samples/servicecontrol/monitoring3rdparty --- -This sample shows how to monitor heartbeat and failed message events in ServiceControl. - -## Prerequisites - - 1. [Install ServiceControl](/servicecontrol/installation.md). - 1. Using [ServiceControl Management](/servicecontrol/license.md#servicecontrol-management-app) tool, set up ServiceControl to monitor endpoints using MSMQ transport. - 1. Ensure the `ServiceControl` process is running before running the sample. +This sample shows how to monitor heartbeat and failed message events in ServiceControl, as well as observing the same activity in ServicePulse. The sample uses the [Learning Transport](/transports/learning/) and a portable version of the Particular Service Platform tools. Installing ServiceControl is **not** required. NOTE: When using the [Azure Service Bus transport](/transports/azure-service-bus/legacy/), the subscribing endpoint must also use the same name shortening strategy as ServiceControl. See the [configuration settings](/transports/azure-service-bus/configuration.md#entity-creation), or if using the [legacy Azure Service Bus transport](), see its [sanitization strategy documentation](/transports/azure-service-bus/legacy/sanitization.md) -NOTE: The ServiceControl endpoint queue name configured in `EndpointsMonitor` must match the name of the ServiceControl instance with the underlying transport naming rules. +downloadbutton + ## Running the project +Running the project will result in 3 console windows: + +1. **NServiceBusEndpoint**: The endpoint that represents the system being monitored. +1. **EndpointsMonitor**: The endpoint that subscribes to ServiceControl heartbeat and failed message events. +1. **PlatformLauncher**: Runs an in-process version of ServiceControl and ServicePulse. When the ServiceControl instance is ready, a browser window will be launched displaying the ServicePulse Dashboard. + The project handles two kinds of events: ### MessageFailed event @@ -34,9 +35,17 @@ A `MessageFailed` event is emitted when processing a message fails and the messa To observe this in action, press Enter in the `NServiceBusEndpoint` console window to send a new `SimpleMessage` event. Processing of the message fails every time. +NOTE: The exception will cause the debugger to enter a breakpoint. It may be preferable to detach the debugger in order to better observe what's going on. + When a `MessageFailed` event is received, the `EndpointsMonitor` prints the following message in its console window: -> `Received ServiceControl 'MessageFailed' event for a SimpleMessage.` +``` +> Received ServiceControl 'MessageFailed' event for a SimpleMessage with ID 42f25e40-a673-61f3-a505-c8dee6d16f8a +``` + +Using the details in the `MessageFailed` message, handler code can be written to notify operations or development staff by email or other method. + +The failed message can also be viewed in the ServicePulse browser window. Navigating to the failed message allows viewing more details about the message failure. ### HeartbeatStopped and HeartbeatRestored events @@ -56,8 +65,6 @@ Next, restart the `NServiceBusEndpoint` application and wait up to 30 seconds. W ## Code walk-through -The solution consists of two projects: `NServicebusEndpoint` and `EndpointsMonitor`. `NServiceBusEndpoint` is a simple endpoint which is monitored by the `EndpointsMonitor`. - ### NServiceBusEndpoint diff --git a/samples/servicecontrol/monitoring3rdparty/CustomChecks_2/Monitoring3rdParty.sln b/samples/servicecontrol/monitoring3rdparty/CustomChecks_2/Monitoring3rdParty.sln index 68e04296143..695ad2ad821 100644 --- a/samples/servicecontrol/monitoring3rdparty/CustomChecks_2/Monitoring3rdParty.sln +++ b/samples/servicecontrol/monitoring3rdparty/CustomChecks_2/Monitoring3rdParty.sln @@ -1,11 +1,12 @@ - Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.26730.12 MinimumVisualStudioVersion = 15.0.26730.12 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample", "Sample\Sample.csproj", "{FAA2FC1D-4554-4AA7-8D5A-334DC8AB601C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample", "Sample\Sample.csproj", "{FAA2FC1D-4554-4AA7-8D5A-334DC8AB601C}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "3rdPartySystem", "3rdPartySystem\3rdPartySystem.csproj", "{6D5CB974-898B-4AD7-83FB-79C4477449FB}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "3rdPartySystem", "3rdPartySystem\3rdPartySystem.csproj", "{6D5CB974-898B-4AD7-83FB-79C4477449FB}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlatformLauncher", "PlatformLauncher\PlatformLauncher.csproj", "{921801B7-71AD-4BA4-A48D-7CCF4E5A9F2D}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -16,8 +17,13 @@ Global {FAA2FC1D-4554-4AA7-8D5A-334DC8AB601C}.Debug|Any CPU.Build.0 = Debug|Any CPU {6D5CB974-898B-4AD7-83FB-79C4477449FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6D5CB974-898B-4AD7-83FB-79C4477449FB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {921801B7-71AD-4BA4-A48D-7CCF4E5A9F2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {921801B7-71AD-4BA4-A48D-7CCF4E5A9F2D}.Debug|Any CPU.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {5E01DC32-A6B7-4F67-8DA0-BE7538B3E5CC} + EndGlobalSection EndGlobal diff --git a/samples/servicecontrol/monitoring3rdparty/CustomChecks_2/PlatformLauncher/PlatformLauncher.csproj b/samples/servicecontrol/monitoring3rdparty/CustomChecks_2/PlatformLauncher/PlatformLauncher.csproj new file mode 100644 index 00000000000..39dace690ee --- /dev/null +++ b/samples/servicecontrol/monitoring3rdparty/CustomChecks_2/PlatformLauncher/PlatformLauncher.csproj @@ -0,0 +1,10 @@ + + + Exe + net461 + 7.1 + + + + + \ No newline at end of file diff --git a/samples/servicecontrol/monitoring3rdparty/CustomChecks_2/PlatformLauncher/Program.cs b/samples/servicecontrol/monitoring3rdparty/CustomChecks_2/PlatformLauncher/Program.cs new file mode 100644 index 00000000000..2e2d89344d6 --- /dev/null +++ b/samples/servicecontrol/monitoring3rdparty/CustomChecks_2/PlatformLauncher/Program.cs @@ -0,0 +1,13 @@ +namespace PlatformLauncher +{ + using System; + + class Program + { + static void Main(string[] args) + { + Console.Title = "PlatformLauncher"; + Particular.PlatformLauncher.Launch(servicePulseDefaultRoute: "/custom-checks"); + } + } +} diff --git a/samples/servicecontrol/monitoring3rdparty/CustomChecks_2/Sample/Program.cs b/samples/servicecontrol/monitoring3rdparty/CustomChecks_2/Sample/Program.cs index 28d3c8fbac4..82b76787329 100644 --- a/samples/servicecontrol/monitoring3rdparty/CustomChecks_2/Sample/Program.cs +++ b/samples/servicecontrol/monitoring3rdparty/CustomChecks_2/Sample/Program.cs @@ -13,6 +13,7 @@ static async Task Main() endpointConfiguration.UseSerialization(); endpointConfiguration.EnableInstallers(); endpointConfiguration.UsePersistence(); + endpointConfiguration.UseTransport(); endpointConfiguration.ReportCustomChecksTo("Particular.ServiceControl"); diff --git a/samples/servicecontrol/monitoring3rdparty/CustomChecks_3/Monitoring3rdParty.Core.sln b/samples/servicecontrol/monitoring3rdparty/CustomChecks_3/Monitoring3rdParty.Core.sln index c4f3558ce29..b3a870d0a86 100644 --- a/samples/servicecontrol/monitoring3rdparty/CustomChecks_3/Monitoring3rdParty.Core.sln +++ b/samples/servicecontrol/monitoring3rdparty/CustomChecks_3/Monitoring3rdParty.Core.sln @@ -1,11 +1,12 @@ - Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.26730.12 MinimumVisualStudioVersion = 15.0.26730.12 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample", "Sample\Sample.Core.csproj", "{FAA2FC1D-4554-4AA7-8D5A-334DC8AB601C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample.Core", "Sample\Sample.Core.csproj", "{FAA2FC1D-4554-4AA7-8D5A-334DC8AB601C}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "3rdPartySystem", "3rdPartySystem\3rdPartySystem.Core.csproj", "{6D5CB974-898B-4AD7-83FB-79C4477449FB}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "3rdPartySystem.Core", "3rdPartySystem\3rdPartySystem.Core.csproj", "{6D5CB974-898B-4AD7-83FB-79C4477449FB}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlatformLauncher.Core", "PlatformLauncher\PlatformLauncher.Core.csproj", "{D3B5AEBE-DC71-43D0-84FC-69895367F943}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -16,8 +17,13 @@ Global {FAA2FC1D-4554-4AA7-8D5A-334DC8AB601C}.Debug|Any CPU.Build.0 = Debug|Any CPU {6D5CB974-898B-4AD7-83FB-79C4477449FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6D5CB974-898B-4AD7-83FB-79C4477449FB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D3B5AEBE-DC71-43D0-84FC-69895367F943}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D3B5AEBE-DC71-43D0-84FC-69895367F943}.Debug|Any CPU.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {4AD8413F-67AD-47A0-BEE2-1DE7701366B0} + EndGlobalSection EndGlobal diff --git a/samples/servicecontrol/monitoring3rdparty/CustomChecks_3/Monitoring3rdParty.sln b/samples/servicecontrol/monitoring3rdparty/CustomChecks_3/Monitoring3rdParty.sln index 68e04296143..6ab83da2f18 100644 --- a/samples/servicecontrol/monitoring3rdparty/CustomChecks_3/Monitoring3rdParty.sln +++ b/samples/servicecontrol/monitoring3rdparty/CustomChecks_3/Monitoring3rdParty.sln @@ -1,11 +1,12 @@ - Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.26730.12 MinimumVisualStudioVersion = 15.0.26730.12 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample", "Sample\Sample.csproj", "{FAA2FC1D-4554-4AA7-8D5A-334DC8AB601C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample", "Sample\Sample.csproj", "{FAA2FC1D-4554-4AA7-8D5A-334DC8AB601C}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "3rdPartySystem", "3rdPartySystem\3rdPartySystem.csproj", "{6D5CB974-898B-4AD7-83FB-79C4477449FB}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "3rdPartySystem", "3rdPartySystem\3rdPartySystem.csproj", "{6D5CB974-898B-4AD7-83FB-79C4477449FB}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlatformLauncher", "PlatformLauncher\PlatformLauncher.csproj", "{91DB06AA-7B6F-4905-9554-433DF1F838D4}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -16,8 +17,13 @@ Global {FAA2FC1D-4554-4AA7-8D5A-334DC8AB601C}.Debug|Any CPU.Build.0 = Debug|Any CPU {6D5CB974-898B-4AD7-83FB-79C4477449FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6D5CB974-898B-4AD7-83FB-79C4477449FB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {91DB06AA-7B6F-4905-9554-433DF1F838D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {91DB06AA-7B6F-4905-9554-433DF1F838D4}.Debug|Any CPU.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {D62918E6-541D-40A1-8457-A14B4C140BDD} + EndGlobalSection EndGlobal diff --git a/samples/servicecontrol/monitoring3rdparty/CustomChecks_3/PlatformLauncher/PlatformLauncher.Core.csproj b/samples/servicecontrol/monitoring3rdparty/CustomChecks_3/PlatformLauncher/PlatformLauncher.Core.csproj new file mode 100644 index 00000000000..2cd030ef38c --- /dev/null +++ b/samples/servicecontrol/monitoring3rdparty/CustomChecks_3/PlatformLauncher/PlatformLauncher.Core.csproj @@ -0,0 +1,10 @@ + + + Exe + netcoreapp2.1 + 7.1 + + + + + \ No newline at end of file diff --git a/samples/servicecontrol/monitoring3rdparty/CustomChecks_3/PlatformLauncher/PlatformLauncher.csproj b/samples/servicecontrol/monitoring3rdparty/CustomChecks_3/PlatformLauncher/PlatformLauncher.csproj new file mode 100644 index 00000000000..39dace690ee --- /dev/null +++ b/samples/servicecontrol/monitoring3rdparty/CustomChecks_3/PlatformLauncher/PlatformLauncher.csproj @@ -0,0 +1,10 @@ + + + Exe + net461 + 7.1 + + + + + \ No newline at end of file diff --git a/samples/servicecontrol/monitoring3rdparty/CustomChecks_3/PlatformLauncher/Program.cs b/samples/servicecontrol/monitoring3rdparty/CustomChecks_3/PlatformLauncher/Program.cs new file mode 100644 index 00000000000..2e2d89344d6 --- /dev/null +++ b/samples/servicecontrol/monitoring3rdparty/CustomChecks_3/PlatformLauncher/Program.cs @@ -0,0 +1,13 @@ +namespace PlatformLauncher +{ + using System; + + class Program + { + static void Main(string[] args) + { + Console.Title = "PlatformLauncher"; + Particular.PlatformLauncher.Launch(servicePulseDefaultRoute: "/custom-checks"); + } + } +} diff --git a/samples/servicecontrol/monitoring3rdparty/sample.md b/samples/servicecontrol/monitoring3rdparty/sample.md index d17cf3aebfa..2ad2e356d13 100644 --- a/samples/servicecontrol/monitoring3rdparty/sample.md +++ b/samples/servicecontrol/monitoring3rdparty/sample.md @@ -10,23 +10,19 @@ redirects: - samples/custom-checks/monitoring3rdparty --- - -## Code walk-through - When integrating with third-party systems, often messages fail when those systems are down. The Particular Platform has extensibility to enable the monitoring of third-party systems which are exposed as HTTP endpoints. This sample shows how to achieve this with custom checks. +downloadbutton -### Third-party system console - -The third-party system console application simulates a HTTP service running on `http://localhost:57789`. Verify that the third-party system is running by opening the url in a browser. When no error is received, the third-party system is running correctly. - +## Running the sample -### The sample console +partial: running -The sample console hosts an endpoint instance which has a custom check associated with it. +Try toggling the status of the 3rd-party system by pressing Enter in the **Samples.CustomChecks.3rdPartySystem** window, and watch the change in output in the **Samples.CustomChecks.Monitor3rdParty** window. +partial: platform -### The custom check +## The custom check The monitoring capability implements a `PeriodicCheck` which calls a defined URI every time the specified interval is elapsed. When the third-party system doesn't respond in a timely fashion a `CheckResult.Failed` event is sent to ServiceControl. diff --git a/samples/servicecontrol/monitoring3rdparty/sample_platform_customchecks_[2,).partial.md b/samples/servicecontrol/monitoring3rdparty/sample_platform_customchecks_[2,).partial.md new file mode 100644 index 00000000000..c4e44db8a9d --- /dev/null +++ b/samples/servicecontrol/monitoring3rdparty/sample_platform_customchecks_[2,).partial.md @@ -0,0 +1 @@ +The status of the custom check is also reported to ServiceControl, and can be viewed in ServicePulse. In the browser window, watch on the ServicePulse **Custom Checks** page as the status is flipped from success to error. In addition to displaying the custom check failure on this page, an overview can also be seen on the ServicePulse **Dashboard** page. \ No newline at end of file diff --git a/samples/servicecontrol/monitoring3rdparty/sample_running_customchecks_[1,2).partial.md b/samples/servicecontrol/monitoring3rdparty/sample_running_customchecks_[1,2).partial.md new file mode 100644 index 00000000000..00a8879455c --- /dev/null +++ b/samples/servicecontrol/monitoring3rdparty/sample_running_customchecks_[1,2).partial.md @@ -0,0 +1,4 @@ +Running the project will result in 2 console windows: + +1. **Samples.CustomChecks.3rdPartySystem**: Represents the 3rd party system by simulating an HTTP service running on `http://localhost:57789`. At startup, the custom check is returning success, but the state can be toggled between success and failure by pressing Enter. +1. **Samples.CustomChecks.Monitor3rdParty**: The endpoint containing the custom check. The success or failure of the 3rd-party system is continuously written to the console. \ No newline at end of file diff --git a/samples/servicecontrol/monitoring3rdparty/sample_running_customchecks_[2,).partial.md b/samples/servicecontrol/monitoring3rdparty/sample_running_customchecks_[2,).partial.md new file mode 100644 index 00000000000..773c567e8a1 --- /dev/null +++ b/samples/servicecontrol/monitoring3rdparty/sample_running_customchecks_[2,).partial.md @@ -0,0 +1,5 @@ +Running the project will result in 3 console windows: + +1. **Samples.CustomChecks.3rdPartySystem**: Represents the 3rd party system by simulating an HTTP service running on `http://localhost:57789`. At startup, the custom check is returning success, but the state can be toggled between success and failure by pressing Enter. +1. **Samples.CustomChecks.Monitor3rdParty**: The endpoint containing the custom check. The success or failure of the 3rd-party system is continuously written to the console. +1. **PlatformLauncher**: Runs an in-process version of ServiceControl and ServicePulse. When the ServiceControl instance is ready, a browser window will be launched displaying the Custom Checks view in ServicePulse. diff --git a/tools/generateNetCoreSamplesInclude.linq b/tools/generateNetCoreSamplesInclude.linq index 05cd0b4e4ee..0907bafdebf 100644 --- a/tools/generateNetCoreSamplesInclude.linq +++ b/tools/generateNetCoreSamplesInclude.linq @@ -80,7 +80,7 @@ private void CreateYamlDeserializer() yamlDeserializer = builder.Build(); } -static Deserializer yamlDeserializer; +static IDeserializer yamlDeserializer; // Define other methods and classes here static SampleMetadata GetSampleMetadata(string path)