Getting Started
Architecture
NServiceBus
Transports
Persistence
ServiceInsight
ServicePulse
ServiceControl
Monitoring
Samples

Connect to ServicePlatform with JSON configuration

NuGet Package: NServiceBus.ServicePlatform.Connector (3.x)
Target Version: NServiceBus 9.x

Introduction

This sample connects an NServiceBus endpoint to the Particular Service Platform and configures:

  • An error queue
  • Message auditing
  • Saga auditing
  • Endpoint heartbeats
  • Custom checks
  • Performance metrics

Code walk-through

Endpoint

A basic NServiceBus endpoint containing a saga, a handler, and a custom check.

The endpoint loads connection details from a file.

var connectionPath = Path.Combine(".", "platformConnection.json");
var json = File.ReadAllText(connectionPath);
var platformConnection = ServicePlatformConnectionConfiguration.Parse(json);

The connection details are used to configure all of the Particular Service Platform features.

endpointConfiguration.ConnectToServicePlatform(platformConnection);

Features can be turned on and off, and configured, by adjusting the configuration file at deployment.

Endpoint features

The endpoint contains:

  • A saga that processes messages triggered by the user, sends a request to a message handler, and waits for a result before marking the saga instance as complete. Connect ServiceInsight to the ServiceControl instance created by PlatformLauncher to view saga audit data.
  • A custom check that toggles the state between success and failure every 30 seconds. Check the Custom Checks tab in ServicePulse to see failures reported here.
  • A message handler that waits half a second before returning a response. This simulates real-world message processing in the Monitoring tab of ServicePulse.

PlatformLauncher

Sets up three instances of ServiceControl (Primary, Audit, and Monitoring) and runs ServicePulse connected to all three.

Running the sample

Run the sample. Once running, press Esc to quit or any other key to send messages. Each message will trigger a saga, which will send a request message to a message handler and wait for a response.

Note the ServiceControl API address in the PlatformLauncher window to connect ServiceInsight to the sample and view message audit and saga audit details.

Related Articles