Question
· Jan 6, 2023

IRIS Interoperability shutdown

Has anybody tried to write custom code to empty out queues when Interoperability shuts down? We run IRIS in Kubernetes cluster and we have compute pods scaling up and down. We have Message Bank operation to keep all messages in one place. We want to see all messages in Message Bank.

Discussion (3)1
Log in or sign up to continue

Sometimes the IKO wants to scale down our compute stateful set while the Interoperability productions are processing messages. A compute will shut down before it empties its queues and we do not see in Message Bank all messages that were processed before the shutdown. I wonder if anybody wrote code to prevent accepting more messages (stop incoming services) and process what is in queues including Message Bank operation queue which could be called before the actual shutdown (preStop hook)?

You can do it like this:

1. Get active production:

w ##class(EnsPortal.Utils).GetCurrentProductionName()

2. Get a list of all BSes in an active production:

SELECT i.Name
FROM Ens_Config.Item i
JOIN %Dictionary.ClassDefinition_SubclassOf('Ens.BusinessService') c ON c.Name = i.ClassName
WHERE Production = ?

3. Disable all BSes (info)

for stop = 1, 0 {
  for i=1:1:$ll(bhList) {
    set host = $lg(bhList, i)
    set sc = ##class(Ens.Director).TempStopConfigItem(host, stop, 0)
  }
  set sc = ##class(Ens.Director).UpdateProduction()
}

4. Wait for all queues to empty:

SELECT TOP 1 1 AS "Processing"
FROM Ens.Queue_Enumerate()
WHERE "Count">0

5. Check that there are no active async BPs (extent size of all BPs must be 0 - here's an example)

6. Stop the production.

w ##class(Ens.Director).StopProduction()

After that and assuming deferred sending is not used (docs) it would be guaranteed that there are no in-flight messages.