Most operation methods used in Rapid Toolkit for Sparkplug producer development operate synchronously (the notable exception to this are the Start and Stop methods). Such methods report errors by throwing an exception, and the possible exceptions are listed in the .NET Assemblies Reference.
The most important asynchronous operations used in Rapid Toolkit for Sparkplug producer development are invoked by the Start Method and Stop Method on the EasySparkplugEdgeNode Class. Aside from asynchronous execution errors and usage errors, methods that invoke asynchronous operations do not throw any exceptions. Instead, the operation outcome is indicated through events that you can handle. In case of the Start and Stop methods, the SystemConnectionStateChanged Event has this purpose (for more information, see Rapid Toolkit for Sparkplug Operation Monitoring Services).
A publishing error occurs when the Sparkplug producer (edge node or device) encounters an error while publishing data.
Publishing error can occur:
Publishing errors are reported through the PublishingError Event on the corresponding Sparkplug edge node (EasySparkplugEdgeNode Class) or device (SparkplugDevice Class). This event represents an error related to publishing of a single message. By default, publishing error is simply reported through this event, but has no other consequences. You can handle this event to implement functionality such as custom error handling or logging for publishing failures.
In some configurations and situations, it is expected to receive publishing errors. For example, if the producer is set to connect to its data source and publish data when the component starts, and the edge node is configured to use primary host application and the application is offline, publishing will fail because the edge node will also be offline.
The example below shows how to process an event when a publishing error occurs.
A write error occurs when the Sparkplug producer (edge node or device) has received data for the metric (through a Sparkplug command), but the metric data cannot be updated, e.g. because of the data type mismatch.
Possible causes of the write error include:
Write errors are reported through the WriteError Event on the corresponding Sparkplug edge node (EasySparkplugEdgeNode Class) or device (SparkplugDevice Class). The event arguments include the name of the metric that has encountered the write error, in the MetricName Property.
Event handlers that you add to events on various Rapid Toolkit for Sparkplug objects are not supposed to throw any exceptions (except for asynchronous execution errors and usage errors). If an exception is thrown anyway, the Rapid Toolkit for Sparkplug handles it by creating an event log entry with information about the exception. For more information, see Component Event Logging.
Sparkplug is a trademark of Eclipse Foundation, Inc. "MQTT" is a trademark of the OASIS Open standards consortium. Other related terms are trademarks of their respective owners. Any use of these terms on this site is for descriptive purposes only and does not imply any sponsorship, endorsement or affiliation.