Class ProcessingContext

  • All Implemented Interfaces:
    java.io.Serializable

    public abstract class ProcessingContext
    extends java.lang.Object
    implements java.io.Serializable
    Context object that allows the user to send a message to a DataSource.
    See Also:
    Serialized Form
    • Constructor Detail

      • ProcessingContext

        public ProcessingContext()
        Default constructor.
    • Method Detail

      • sendToDataSource

        public abstract SendingResult sendToDataSource​(byte[] payload)

        Sends a message to a data source. This will route messages through the connector back to the data source.

        if the datasource is simulation instance, then the message will be sent to the simulation model's implementation of the MessageProcessor.

        Parameters:
        payload - the message (as a serialized JSON string)
        Returns:
        the sending result
      • sendToDataSource

        public abstract SendingResult sendToDataSource​(java.lang.Object jsonSerializableMessage)

        Sends a message to a data source. This will route messages through the connector back to the data source.

        if the datasource is simulation instance, then the message will be sent to the simulation model's implementation of the MessageProcessor.

        Parameters:
        jsonSerializableMessage - a JSON serializable message.
        Returns:
        the sending result
      • sendToDataSource

        public abstract SendingResult sendToDataSource​(java.util.List<java.lang.Object> jsonSerializableMessages)

        Sends a list of messages to a data source. This will route messages through the connector back to the data source.

        if the datasource is simulation instance, then the message will be sent to the simulation model's implementation of the MessageProcessor.processMessages(ProcessingContext, DigitalTwinBase, Iterable).

        Parameters:
        jsonSerializableMessages - a list of JSON serializable messages.
        Returns:
        the sending result
      • sendToDigitalTwin

        public abstract SendingResult sendToDigitalTwin​(java.lang.String model,
                                                        java.lang.String id,
                                                        byte[] payload)

        This method sends a serialized JSON message to a real-time digital twin

        Note, the message contents must be serialized so that the registered message type of the digital twin model will be sufficient to deserialize the message.

        Parameters:
        model - the model of the digital twin
        id - the id of the digital twin
        payload - the serialized JSON message
        Returns:
        the sending result
      • sendToDigitalTwin

        public abstract SendingResult sendToDigitalTwin​(java.lang.String model,
                                                        java.lang.String id,
                                                        java.lang.Object jsonSerializableMessage)

        This method sends a serialized JSON message to a real-time digital twin

        Note, the message contents must be serialized so that the registered message type of the digital twin model will be sufficient to deserialize the message.

        Parameters:
        model - the model of the digital twin
        id - the id of the digital twin
        jsonSerializableMessage - a JSON serializable message object
        Returns:
        the sending result
      • sendToDigitalTwin

        public abstract SendingResult sendToDigitalTwin​(java.lang.String model,
                                                        java.lang.String id,
                                                        java.lang.String payload)

        This method sends a JSON message to a real-time digital twin

        Note, the message contents must be serialized so that the registered message type of the digital twin model will be sufficient to deserialize the message.

        Parameters:
        model - the model of the digital twin
        id - the id of the digital twin
        payload - the JSON message
        Returns:
        the sending result
      • sendToDigitalTwin

        public abstract SendingResult sendToDigitalTwin​(java.lang.String model,
                                                        java.lang.String id,
                                                        java.util.List<byte[]> payload)

        This method sends a list of serialized JSON message to a real-time digital twin

        Note, the message contents must be serialized so that the registered message type of the digital twin model will be sufficient to deserialize the message.

        Parameters:
        model - the model of the digital twin
        id - the id of the digital twin
        payload - the JSON message
        Returns:
        the sending result
      • sendAlert

        public abstract SendingResult sendAlert​(java.lang.String alertingProviderName,
                                                AlertMessage alert)

        This method sends an alert message to supported systems. See "TODO: Link to docs" for more details on supported systems.

        When a model is deployed, an optional alerting provider configuration can be supplied. The provider name corresponds to the name of the configured alerting provider. For example, if an alerting provider configuration is called "SREPod1", then the processing context will send an alert message to the alerting provider configured with the name "SREPod1".

        If the message cannot be sent then SendingResult.NotHandled will be returned. If the message is sent and in process of sending then SendingResult.Enqueued will be returned. Once the message is successfully sent then the returned enum will be changed to SendingResult.Handled.

        Parameters:
        alertingProviderName - the alerting provider name. Note, must match a valid configuration.
        alert - the alert message.
        Returns:
        the sending result.
      • getPersistenceProvider

        public abstract PersistenceProvider getPersistenceProvider()
        Returns the configured persistence provider or null if no persistence provider configuration can be found.
        Returns:
        a PersistenceProvider .
      • getDataSourceId

        public abstract java.lang.String getDataSourceId()
        Retrieve the unique Identifier for a DataSource (matches the Device/Datasource/Real-time twin ID)
        Returns:
        the digital twin id
      • getDigitalTwinModel

        public abstract java.lang.String getDigitalTwinModel()
        Retrieve the model for a DigitalTwin (matches the model of a Device/Datasource/real-time twin)
        Returns:
        the digital twin model
      • logMessage

        public abstract void logMessage​(java.util.logging.Level severity,
                                        java.lang.String message)
        Logs a message to the real-time digital twin cloud service. Note: the only supported severity levels are: INFO, WARN, and SEVERE
        Parameters:
        severity - the severity of the log message
        message - the message to log
      • getCurrentTime

        public abstract java.util.Date getCurrentTime()
        Retrieves the current time. If the model (simulation or real-time) is running inside of a simulation then the simulation time will be returned.
        Returns:
        The current time (real time, or simulation if running under simulation).
      • getSharedModelData

        public abstract SharedData getSharedModelData()
        Retrieve a SharedData accessor for this model's shared data.
        Returns:
        a SharedData instance.
      • getSharedGlobalData

        public abstract SharedData getSharedGlobalData()
        Retrieve a SharedData accessor for globally shared data.
        Returns:
        a SharedData instance.