Configuring the Results Services

Topic Contents [Hide]Topic Contents [Show]
  1. Database Connections
  2. AppSettings for Results Services
  3. Provider Options for Dockers

The services are primarily configured during the CM4D Results Services installation. Following installation, these settings are also available via the appsettings.json file in the corresponding service directory. The configuration in the file is overwritten by information from other configuration providers that define certain key/value pairs. This is mainly relevant for docker installations.

Database Connections

The connections strings for the CM4D Site Database and CM4D Results Database are the most important settings as they allow the services to connect to one another.

If CM4D is installed on the same machine, the database connections are typically set via the CM4D.4ds file. However, this is not the case for Docker containers where the settings are typically set via environment variables. The Results Loader service can work without any connection to the CM4D Site database (e.g. in the cloud connected via a RabbitMQ queue) if the CM4DDSFilePath parameter it is explicitly set in the appsettings.json or via an environment variable.

If CM4D is installed on the same machine, the database connections are typically set via the CM4D.4ds file. However, this is not the case for Docker containers where the settings are typically set via environment variables. The Results Loader service can work without any connection to the CM4D Site database (e.g. in the cloud connected via a RabbitMQ queue) if the CM4DDSFilePath parameter it is explicitly set in the appsettings.json or via an environment variable.

AppSettings for Results Services

This document describes the configuration variables stored in the services' appsettings.json files for Results services configuration. All elements can be configured to align with different system requirements.

Application settings for the running service can depend on multiple sources, environment variables, client secrets, Azure Key Vault and from a file appsettings.json. Each layer of configuration belongs to a specific hierarchy, which will not be fully covered in this document.

Each of the Results services has its own appsettings file and although some elements are common to all of the Results services, others may be isolated for a specific service. Hover the cursor over the element label footnote where indicated (e.g., Outbox) for quick information or jump to the key here.

Configuration

ResultsConcurrencyLimitResults Loader Only: The number of threads Results Loader will use to process results concurrently (at the same time). The default is set to unlimited (0), but you may set this to a set number of processing threads. Keep in mind that this is system depends on the server hardware and the number of CM4D instances that are run by Results Launcher, so each thread greater than one will increase the resource consumption on that system. You may need to try different settings per computer to find the optimal performance for Results Loader threads.

ExportRootStreamCacheSmith OnlyThe path to the folder used by StreamCacheSmith to store 3D model files for CM4D Peruse that are exported from CM4D. The StreamCacheSmith service creates any necessary subfolders in this root location. HOOPS Communicator references this directory to load 3D Models in CM4D Peruse.


  "Configuration": {
    "ResultsConcurrencyLimit": 0
  },

 
  "Configuration": {
     "ExportRoot": "\\\\server\\atscm4d\\Models\\"    },

Connection Strings

ResultsDatabaseResults Loader and StreamCacheSmith**: Connection string to ATS CM4D Results database. Only required here if not running the service locally to the CM4D installation and cannot connect directly using the 4DS file.

SiteDatabase: Connection string to ATS CM4D Site database. Only required here if not running the service locally to the CM4D installation and cannot connect directly using the 4DS file.


  "ConnectionStrings": {
    "ResultsDatabase": "server=(local);database=CM4DResults;user id=username;password=pass;TrustServerCertificate=Yes;",
    "SiteDatabase": "server=(local);database=CM4DSite;user id=username;password=pass;TrustServerCertificate=Yes;"
  },

NServiceBus

ServiceControl: Facilitates and monitors messages between the CM4D and Results databases.

  • AuditQueue: The audit queue name (optional - leave empty unless asked to enable it by support).
  • ErrorQueue: The error queue name.
  • ServiceControlQueue: The name of the Service Control instance; must match the Service Control instance. This queue is used to store information about the service. Please note that some transport types (e.g., Azure Storage Queues) may have label formatting restrictions.
  • MonitoringQueue: The name of the ServiceControl Monitoring instance. This queue is used to store information about the service used for monitoring purposes. Please note that some transport types (e.g., Azure Storage Queues) may have label formatting restrictions.
    AzureDelayQueueResults Sender Only*


    "ServiceControl": {
      "AuditQueue": "",
      "ErrorQueue": "error",
      "ServiceControlQueue": "Particular.ServiceControl",
      "MonitoringQueue": "Particular.Monitoring"
    },

Endpoint:

  • NameThe endpoint name, or full name of the service.
  • LimitMessageProcessingConcurrencyToResults Sender Only*: The number of messages processed concurrently. The number of entries in the Results export queue (used during processing Results from CM4D to the Results database) can become busy if you are moving a large amount of data. Customizing the processing configuration may improve overall performance. Set this option to the number of commands processed in each transaction [default: 1].
  • OutboxStreamCacheSmith Only: Maintenance options for the database table used by StreamCacheSmith.
    • CleanupInterval: 
    • RetentionTime: 


    "Endpoint": {
      "Name": "ATS.CM4D.Conestoga.ResultsEndpoint",
      "LimitMessageProcessingConcurrencyTo": 1,

 

 


      "Outbox": {
        "CleanupInterval": 60,
        "RetentionTime": 86400

 

  • Recoverability: Set behavior for handling fail/delay conditions within the results transport process.
    • ImmediateRetries: The number of times [default: 3] the service immediately attempts to retry processing a message that did not process successfully. Once this number is depleted, the message is considered delayed.
    • DelayedRetries: The number of times [default: 3] the service attempts to try processing messages that could not be processed immediately before the message is marked as failed.
    • RetryFailedAfterResults Sender Only*: Jobs that failed to process (after immediate and delayed retries) are reset to Status 1 waiting to be processed after the specified period of time. Only jobs created by this local instance of the service are reset. Each instance running in the system create/reset their own jobs. Value represents minutes [default: 30], and can be set as low a 5 minutes since it is only checking the job status for one instance.
    • GlobalRetryFailedAfterResults Sender Only*: Similar to RetryFailedAfter, but it picks up all jobs that are in Processing (Status 2) regardless of the Sender ID, but have not been finished. This is used primarily when you have multiple instances of the Results sender throughout your system, particularly in cases where the services are run in a docker container. When running the services as a docker container, each time an instance is created it has a new ID, which could potentially leave unprocessed jobs stuck (error status 1000) without a Results sender with the originating ID currently running. If the machine that originally put the job into processing is no longer available, eventually the Global Retry sends the job to the next Results Sender available. Value represents hours [default: 10] and should not be set lower than 5 hours. The larger the Job Batch size (e.g., 100) the longer the Global Retry time should be set. If amount of time is too low, it can cause issues with how the data gets processed and could result in errors. At this time, there is no option to designate how many times failed jobs are retried.


      "Recoverability": {
        "ImmediateRetries": 3,
        "DelayedRetries": 3,
        "RetryFailedAfter": 30,
        "GlobalRetryFailedAfter": 10

 


 

  • Transport: The NServiceBus transport is the way the messages are sent from one node to another. The system can be a distributed deployment, such as a local CM4D Site database and a cloud-based Results database.
    • Name: The name of the configured transport type. Options: SQL, RabbitMQ, AzureStorageQueues.
    • TransactionMode: The transaction mode; it is recommended this be set to ReceiveOnly, as other options may interfere with the results services.
    • ConnectionString: Connection string to the transport data storage; format is dependent on the transport type configured.
    • AzureQueueInvisibleTimeResults Sender Only*: Applies to Azure Storage Queues transport only; sets the time in seconds [default: 30] a message is reserved for a Loader or StreamCacheSmith instance to process jobs. It is marked as reserved by a particular thread for the set amount of time before it can potentially be picked up by another thread for processing elsewhere, preventing duplicate processing loops with other Results service instances. Why use this option?Why use this option?The default setting of 30 seconds is sufficient for the majority of cases, especially if you only run one instance of the services. However, if you have an environment running multiple instances of the Results services or if your CAD files are very large, consider increasing this timeframe to ensure efficient processing. Check the EventViewer log for the error "Exceeds the Message Invisible Time".
    • EnableCompressionResults Sender and Loader††: Applies to Azure Storage Queues transport only; enables/disable message compression. Azure has a limitation on the size of messages that can be sent/received, so without compression any messages exceeding that limit will fail. For example, if you transfer data to the Results db that includes a large amount of information (e.g., many baselines) per feature, messages could exceed the size limitation imposed by Azure and fail to send. When Compression is enabled (True), all messages are briefly checked for size and any that do not exceed the Azure limit are processed without compression, and those that are larger than the size limit are compressed before sending. Compression will effect the processing speed to some extent, but the messages will not fail due to size. Even if this element is not present in the appsettings file, messages are Uncompressed (default: False). Why use this option?Why use this option?If you use Azure Storage Queues as your Transport type and see EventViewer errors notifying you that a message size limit was exceeded, enable this setting to compress any messages exceeding the ASQ limit.


      "Transport": {
        "Name": "SQL",
        "TransactionMode": "ReceiveOnly",
        "ConnectionString": "",
        "AzureQueueInvisibleTime": 30,
        "EnableCompression": 10
      },

 

  • Persistence: Information about messages might need to be stored to ensure transactional consistency of long-running transactions.
    • Name: The name of the persistence option that is configured. Options: SQL.
    • ConnectionString: Connection string to the persistence data storage; format dependent on the persistence option configured. It is recommended to store it in the CM4D Site database, but another database can be configured if necessary. Only required here if not running the service locally to the CM4D installation and cannot connect directly using the 4DS file.


      "Persistence": {
        "Name": "SQL",
        "ConnectionString": "Data Source=SERVER;Initial Catalog=DATABASE;User ID=Username;  
        Password=pass1234; TrustServerCertificate=True;MultipleActiveResultSets = True"

SerilogConfiguration section for Serilog log functionality. Logging of information is important for troubleshooting of services. The following logging options are available:

  • UsingResults Sender Only*: The Serilog sink for rolling files based on size and time.
  • MinimumLevel: The level of log tracing. Options: Critical, Error, Warning (default), Information, Debug, Trace, and None.
  • EnableInsightKey: Set to "True" to use Application Insights (Microsoft Azure technology used for logging and monitoring).
  • InsightKey: Setup key for Application Insights instance.
  • EventLogCommon for windows-based systems. However, it is not recommended to log more debug or trace information to the event log.
  • EventLogRestictedToMinimumLevel: Set the minimum level for event log logging.
  • EventLogOutputTemplate: Set the format for the output event data.
  • EventLogManagedEventSource: Set to "True" for the service to register the event source. This requires local admin rights for the user running the services.
  • WriteTo: Sinks are configured using the WriteTo configuration object. There are more than one set of Name/Args (Console and File), which must be enumerated for docker containers.
    • Name: Specifies which logs are generated, Console or File. File requires additional parameters (args, paths, etc.)
    • Args: Specifies in which folder to write, along with additional specifications for how the file is written and handled by the system.
      • path: File path for writing log events. This must be writable.
      • outputTemplate: Defines the format or template for how log events will be rendered when they are written to that particular sink.
      • fileSizeLimitBytes: The maximum size that a log file can reach before it's closed and a new log file is created.
      • rollingInterval: Specifies the frequency at which the log file should rolled or rotated.
      • rollOnFileSizeLimit: Specify (True/False) whether or not log files should be rolled over (archived and a new file started) when a certain file size limit is reached.
      • retainedFileCountLimit: Manages the number of log files retained when logging to a file sink.
  • Enrich: Enrich the property of the log from the log context.
  • Properties:


  "Serilog": {
    "Using": [
      "Serilog.Sinks.Console"
    ],
    "MinimumLevel": "Information",
    "EnableAppInsight": false,
    "InsightKey": "",
    "EventLogRestrictedToMinimumLevel": "Warning",
    "EventLogOutputTemplate": "{Message}{NewLine}{Exception}",
    "EventLogManageEventSource": false,
    "WriteTo": [
      {
        "Name": "Console",
        "Args": {
          "outputTemplate": "{Timestamp:o} [{Level:u3}] [{ThreadId}] ({Application}/{MachineName}) {Message}{NewLine}{Exception}"
        }
      },
      {
        "Name": "File",
        "Args": {
          "path": "./logs/log_.txt",
          "outputTemplate": "{Timestamp:o} [{Level:u3}] [{ThreadId}] ({Application}/{MachineName}) {Message}{NewLine}{Exception}",
          "rollingInterval": "Day",
          "fileSizeLimitBytes": "2097152",
          "rollOnFileSizeLimit": true,
          "retainedFileCountLimit": 2000
        }
      }
    ],
    "Enrich": [
      "FromLogContext",
      "WithMachineName",
      "WithThreadId"
    ],
    "Properties": {
      "Application": "ResultsLoader",
      "MachineName": "MachineATS"
    }

  }

Allowed HostsResults Sender Only*: Specifies a list of hostnames that are allowed to access the application. By default, this is set to a wildcard to allow all hosts. Multiple hosts are separated with a comma.

Process DataSourcesResults Sender Only*: Restrict a Results Sender instance to process only specified Managed Datasources; filter by all datasources in a Site or by Site/Datasource label. The Results Sender service processes the database changes in CM4D for export. Distributed installations with databases in different regions that are organized within a single Site may cause inefficiencies. For example, if a Results Sender service in Europe processes changes for a database in Asia. A configuration option allows you to restrict a Results Sender instance to process only specified Managed Datasources. It is possible to configure a datasource via DataSource label or to specify a Site and include all Datasources in that Site. Hide optionsShow options

  • All DataSources ["*/*"] - Include all DataSources in the Site using an asterisk in place of the Site and DataSource labels, separated by a forward slash (*/*). This is the default configuration if the parameter is empty or missing.
  • All DataSources in a Site ["Site/*"] - Include all DataSources in the specified Site.
  • Multiple DataSources ["Site/DB","Site/DB"] -  Include multiple specified DataSources. Each definition contains a Site label and a DataSource label separated by a forward slash (Site/DataSource). Additional Datasources can be specified by separating the Site/DB labels with a comma.

Max Parallel ProcessingResults Sender Only*: Maximum number of parallel Routines to be processed if the complete database is transferred [default: 10].

Job Batch SizeResults Sender Only*: The number of entries in the Results export queue (used during processing Results from CM4D to the Results database) can become busy if you are moving a large amount of data. Customizing the processing configuration may improve overall performance. Set this option to the number of commands processed in each transaction [default: 100].

Scan Queue Interval When IdleResults Sender Only*: Milliseconds between two table scans if no entry was processed [default: 1000].

Scan Queue Interval When FoundResults Sender Only*:Milliseconds between two table scans if entries have been processed [default: 100].

Remove Processed AfterResults Sender Only*: Set the length of time that records are retained in the ResultsCommandQueue database table;

 

values is minutes to wait before deleting commands that have been processed (Status: 2) [default: 2880].


  },
  "AllowedHosts": "*",
  "ProcessDatasources": ["*/*"],
  "MaxParallelProcessing": "10",
  "JobBatchSize": "100",
  "ScanQueueIntervallWhenIdle": "1000",
  "ScanQueueIntervallWhenFound": "100",
  "RemoveProcessedAfter": "2880"
}


Footnote Key
* Results Sender Only
** Results Loader and StreamCacheSmith Only
Results Loader Only
†† Results Sender and Loader Only
StreamCacheSmith Only

Provider Options for Dockers

File: The primary configuration provider uses the appsettings.json file in the corresponding service directory.


Environment Variable Configuration
: Hierarchy levels are separated by a double underscore.

“section1”: {
       “section2”: {
             “key”: “value”
             }
      }
}

In an appsettings.json file this would be:

 set section1__section2__key=”value”


Command Line
: Key/value pairs can be passed via the command line in three ways:

  1. with a -- and =: --section1__section2__key=”value”
  2. with a -- and a space: --section1__section2__key ”value”
  3. with a / and a space: /section1_section2__key “value”


CM4D.4ds
: A CM4D.4ds provider can set the following two parameters from the CM4D Site database. The CM4D.4ds file is located via the registry key HKEY_LOCALMACHINE\Software\Applied Tech Systems\CM4D (Windows machines only) or the location of the service assembly. The file path can be set explicitly via the configuration key “CM4D4DSFilePath” in the appsettings.json file.

{ “ConnectionStrings”: {
             “SiteDatabase”: “”,
             “ResultsDatabase”:””
             }
}

 

Can we improve this topic?