Java concurrent queue for tag change scripts

Did you read the linked topic in the first post?

Some more about this:

system.util.invokeAsynchronous() is a very heavy-weight tool and should not be used where you could make hundreds or thousands of threads.

Oh, I looked over that link in the first post. That clarifies the use case allot, thanks!

Hey @pturmel, how does this work with redundant gateways? What will happen to enqueued items if the redundant gateway kicks in? I assume these are dropped if the GW goes down. How would you make it more tolerant?

Dropped on failover.

You will need a bunch of state management in your queue draining routine to detect when it is newly "live" after fail-over, and run discovery/recovery code.

Ignition redundancy isn't really designed for seamless state hand-off in any case.

3 Likes

Another question that comes to mind:

In an expression tag, is using runScript on a timer subject to the same vulnerability? Or is that an entirely different system in Ignition?

Yes, it is a separate thread pool for expressions, but is also size three. Scripts won't block expressions and vice versa, but long-running expressions can block all tag expression execution.

1 Like

I have been trying to get queueUtil to work, failing hard.... :frowning:

I am confused maybe someone, pturmel, or nminchin explain:

what exactly goes into the tagChange script?
what exactly goes into the Gateway Event Timer script?

Did you read the multiline comment string between the copyright and the imports? Examples right there.

Let me summarize:

  • In those examples, replace "ABC" with some reasonable name for what you are doing.

  • Place queueUtil.py into a library script named queueUtil in an inheritable project that will be included in both your gateway scripting project and whatever project will run the timer events.

  • In the gateway scripting project, create a library script to contain the assignment to processABCqueue and the function definition enqueueABC.

  • In every tag (or UDT) that need to run this process. make a value change event with the one-liner someScriptGSP.enqueueABC(...) as described in the comment above that example.

  • In the background events project, create a library script to contain the assignment to processABCqueue and the function definition processABC, including the decorator.

  • In one or more (if workload justifies) timer events in the background project, make one-liner calls to someScriptBG.processABC(). (No arguments.)

Also, make sure my Integration Toolkit is installed.

I have the Integration Toolkit installed.

I put queueUtil in my gateway scripting project, currently gateway inheritance is a single project. Not a structure like your docstring calls out.

processABCqueue and the function definition enqueueABC.
I did not understand needed to be in a separate library project.

I unfortunately will not be able to do anymore ignition work until next week, going on vacation.

Ill report back when I am successful.

Thank you! Your advice is very valuable.

Ok, Can be one script in a single project. The docstring calls out the requirements based on split duties for different kinds of projects.

I got queueUtil working! Thank you again for providing the community with your time, software, and expertise. I have solved many problems using your advice.

3 Likes