Insert data in a custom table with the S&F protection

According to the doc:

Store and Forward Connection Policy

Database connections by default have a pool of eight connections. The Store and Forward engine is multi-threaded, meaning the engine can take advantage of more than one of these connections at a time. This also means that if the Store and Forward engine is storing a particular type of data, such as tag history, that action will not block the engine from concurrently storing a different type of data, such as Alarm Journal or Audit Profile data.

There are six different types of data that can be stored and forwarded, meaning up to six of your available connections can be used at the same time. Each available data type is listed below:

  • Alarming
  • Auditing
  • Scripting
  • SECS/GEM
  • Tag history
  • Transaction Group

I suppose that my module use case is similar to scripting feature
available with system.db.runSFPrepUpdate(query, args, datasources)
as I need to insert data in a custom table with the S&F protection

if someone can share the type of persistent data to use or an example ?

I don't find a "scripting" or something to type to deal with custom table in PersistentData ?

Perhaps we have to use AbstractDatasourceSink ?

The data that's ultimately passed in to the rest of the system is an instance of com.inductiveautomation.ignition.gateway.datasource.storage.QuerySFData.
The StorageKey is created with the com.inductiveautomation.ignition.gateway.storeforward.StorageKey.repeated factory using the database connection name.

        var manager = context.getStoreAndForwardManager();
        for (StorageKey storageKey : storageKeys) {
            try {
                manager.storeData(storageKey, new QuerySFData(query, values, storageKey.engineId()));
1 Like

it seems that QuerySFData is an internal class not available in the SDK...

Ah, yeah, it sure is. I was going to recommend you stand up your own similar class, but there's some complications if you're dealing with arbitrary objects as query parameters that you need to serialize, and I don't know how the experience of doing that as an external user will go...

I'll see if I can get someone with S+F experience to chime in on a 'recommended' path here.

Thanks !
For my use case, I've found a workaround. I will put some code outside the module in order to script using system.db.runSFPrepUpdate.
Another way is perhaps to invoke the scriptManager and the system.db.runSFPrepUpdate but it's a bit anti-pattern for a module.