Methods in Rapid Toolkit for Sparkplug that operate synchronously report errors by throwing an exception, and the possible exceptions are listed in the .NET Assemblies Reference. For errors arising from Sparkplug operations, Rapid Toolkit for Sparkplug uses the SparkplugException Class.
In Sparkplug consumer development, this applies primarily to the PublishPayload Method used for publishing Sparkplug commands, and the extensions methods built on top of it, i.e.
The following example illustrates proper handling when publishing a Sparkplug command.
Example
Aside from asynchronous execution errors and usage errors, methods in Rapid Toolkit for Sparkplug that invoke asynchronous operations do not throw any exceptions. Instead, the operation outcome is indicated through events or callbacks that you can handle.
In Sparkplug consumer development, this applies primarily to methods that subscribe to or unsubscribe from Sparkplug data, such as:
and also the extension methods built on top of them.
Errors arising from and related to Sparkplug subscriptions are reported through the same channels as the received Sparkplug data in case of success. The channels are:
The events and callbacks receive event arguments that are of EasySparkplugMetricNotificationEventArgs Class or EasySparkplugPayloadNotificationEventArgs Class - and in both cases, they derive from the OperationEventArgs Class. This means that among other available members, you can use following properties to obtain and inspect the outcome of the operation (status of the subscription):
The following example illustrates processing of subscription callbacks, and shows how to detect and handle a notification that denotes a failure.
Example
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.