Getting Started
Architecture
NServiceBus
Transports
Persistence
ServiceInsight
ServicePulse
ServiceControl
Monitoring
Samples

Connecting endpoints

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

The ServicePlatform Connector plugin provides a unified API to connect an NServiceBus endpoint to the Particular Service Platform by configuring:

JSON

The connection details can be parsed from JSON-compliant text with a specific configuration schema.

var json = File.ReadAllText(pathToJson);
var platformConnection = ServicePlatformConnectionConfiguration.Parse(json);

endpointConfiguration.ConnectToServicePlatform(platformConnection);

The JSON file looks like this:

{
  "ErrorQueue": "myErrorQueue",
  "Heartbeats": {
    "Enabled": true,
    "HeartbeatsQueue": "heartbeatsQueue"
  },
  "CustomChecks": {
    "Enabled": true,
    "CustomChecksQueue": "customChecksQueue"
  },
  "MessageAudit": {
    "Enabled": true,
    "AuditQueue": "myAuditQueue"
  },
  "SagaAudit": {
    "Enabled": true,
    "SagaAuditQueue": "sagaAuditQueue"
  },
  "Metrics": {
    "Enabled": true,
    "MetricsQueue": "metricsQueue",
    "Interval": "00:00:10"
  }
}

A JSON file specific to a concrete deployment of the ServicePlatform is available via ServicePulse.

Screenshot of ServicePulse showing the configuration endpoint connection json file tab

Code first

The connection details can be constructed in code.

var platformConnection = new ServicePlatformConnectionConfiguration
{
    ErrorQueue = "myErrorQueue",
    Heartbeats = new ServicePlatformHeartbeatConfiguration
    {
        Enabled = true,
        HeartbeatsQueue = "heartbeatsQueue"
    },
    CustomChecks = new ServicePlatformCustomChecksConfiguration
    {
        Enabled = true,
        CustomChecksQueue = "customChecksQueue"
    },
    MessageAudit = new ServicePlatformMessageAuditConfiguration
    {
        Enabled = true,
        AuditQueue = "myAuditQueue"
    },
    SagaAudit = new ServicePlatformSagaAuditConfiguration
    {
        Enabled = true,
        SagaAuditQueue = "sagaAuditQueue"
    },
    Metrics = new ServicePlatformMetricsConfiguration
    {
        Enabled = true,
        MetricsQueue = "metricsQueue",
        Interval = TimeSpan.FromSeconds(60)
    }
};

endpointConfiguration.ConnectToServicePlatform(platformConnection);

Combined

It is possible to load configuration from JSON and then override settings via code.

var json = File.ReadAllText(pathToJson);
var platformConnection = ServicePlatformConnectionConfiguration.Parse(json);

platformConnection.Heartbeats.Enabled = false;
platformConnection.Metrics.InstanceId = "MyCustomInstanceId";

endpointConfiguration.ConnectToServicePlatform(platformConnection);

Samples

Related Articles