AI agents: use the documentation index at llms.txt to locate machine-readable pages. This section is indexed by https://docs.particular.net/samples/llms.txt. The markdown version of this page is served as plain text. An MCP server at /mcp serves the same content via the search_docs and read_doc tools; it is read-only and needs no credentials. Markdown versions of documentation pages are available by appending .md to the page URL. Directory URLs use index.md. They are served as text/plain because some retrieval backends reject text/markdown.

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 ServicePulse 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 ServicePulse to the sample and view message audit and saga audit details.

Related Articles