Getting Started
Architecture
NServiceBus
Transports
Persistence
Hosting
ServiceInsight
ServicePulse
ServiceControl
Monitoring
Modernization
Samples

Connecting endpoints

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 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

Configuration can be loaded from JSON and then overridden in 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