Created
March 24, 2026 18:40
-
-
Save eduard93/8c7c8f66140690238bea5b18d557df26 to your computer and use it in GitHub Desktop.
Sample LOCK usage with InterSystems IRIS Interoperability
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8"?> | |
| <Export generator="IRIS" version="26" zv="IRIS for Windows (x86-64) 2025.1 (Build 223U)" ts="2026-03-24 14:39:13"> | |
| <Class name="Lock.BO"> | |
| <Super>Ens.BusinessOperation</Super> | |
| <TimeChanged>67653,51947.0302151</TimeChanged> | |
| <TimeCreated>67634,37823.4163368</TimeCreated> | |
| <Method name="OnMessage"> | |
| <FormalSpec>pRequest:Ens.StringContainer,*pResponse:Ens.Response</FormalSpec> | |
| <ReturnType>%Status</ReturnType> | |
| <Implementation><![CDATA[ | |
| Set sc = $$$OK | |
| Try { | |
| $$$TRACE("Request Shared lock") | |
| LOCK +^Lock.RefData("ref")#"S" | |
| $$$TRACE("Gained Shared lock") | |
| Try { | |
| $$$TRACE("Request Exclusive lock") | |
| LOCK +^Lock.RefData("ref") | |
| $$$TRACE("Gained Exclusive lock.") | |
| Try { | |
| $$$TRACE("Simulate the purge work") | |
| &sql(DELETE FROM Lock.RefData) | |
| Hang +pRequest.StringValue | |
| Set obj = ##class(Lock.RefData).%New() | |
| Set obj.Value = $zdt($h,3,1,3) | |
| Do obj.%Save() | |
| $$$TRACE("Release exclusive lock on succesfull completion") | |
| LOCK -^Lock.RefData("ref") | |
| } Catch ex { | |
| $$$TRACE("Release exclusive lock on error") | |
| LOCK -^Lock.RefData("ref") | |
| THROW ex // re-throw the exception after releasing lock | |
| } | |
| $$$TRACE("Release shared lock on successfull completion") | |
| LOCK -^Lock.RefData("ref")#"S" | |
| } Catch ex { | |
| $$$TRACE("Release shared lock on error") | |
| LOCK -^Lock.RefData("ref")#"S" | |
| THROW ex // re-throw the exception after releasing lock | |
| } | |
| } Catch ex { | |
| Set sc = ex.AsStatus() | |
| } | |
| Set pResponse = ##class(Ens.Response).%New() | |
| $$$TRACE("Done.") | |
| Quit sc | |
| ]]></Implementation> | |
| </Method> | |
| </Class> | |
| <Class name="Lock.BS"> | |
| <Super>Ens.BusinessService</Super> | |
| <TimeChanged>67653,51849.4608614</TimeChanged> | |
| <TimeCreated>67634,38949.5799059</TimeCreated> | |
| <Parameter name="ADAPTER"> | |
| <Default>Ens.InboundAdapter</Default> | |
| </Parameter> | |
| <Property name="Target"> | |
| </Property> | |
| <Parameter name="SETTINGS"> | |
| <Default><![CDATA[Target:Basic:selector?multiSelect=0&context={Ens.ContextSearch/ProductionItems?targets=1&productionName=@productionId}]]></Default> | |
| </Parameter> | |
| <Method name="OnProcessInput"> | |
| <FormalSpec>pInput:%RegisteredObject,*pOutput:%RegisteredObject</FormalSpec> | |
| <ReturnType>%Status</ReturnType> | |
| <Implementation><![CDATA[ | |
| Set msg = ##class(Ens.Request).%New() | |
| Set sc = ..SendRequestAsync(..Target, msg) | |
| Quit sc | |
| ]]></Implementation> | |
| </Method> | |
| </Class> | |
| <Class name="Lock.CF"> | |
| <Super>Ens.Rule.FunctionSet</Super> | |
| <TimeChanged>67653,51764.5638537</TimeChanged> | |
| <TimeCreated>67634,38391.6757866</TimeCreated> | |
| <Method name="GetRefData"> | |
| <Description> | |
| zw ##class(Lock.CF).GetRefData()</Description> | |
| <ClassMethod>1</ClassMethod> | |
| <ReturnType>%String</ReturnType> | |
| <Implementation><![CDATA[ | |
| $$$TRACE("Request Shared lock") | |
| LOCK +^Lock.RefData("ref")#"S" | |
| $$$TRACE("Gained Shared lock") | |
| Try { | |
| Set rs = ##class(%SQL.Statement).%ExecDirect(,"SELECT Value FROM Lock.RefData") | |
| } Catch ex { | |
| LOCK -^Lock.RefData("ref")#"S" | |
| Return "EX - NO DATA" | |
| } | |
| if 'rs.%Next() | |
| { | |
| $$$TRACE("NO DATA, Releasing lock") | |
| LOCK -^Lock.RefData("ref")#"S" | |
| Quit "SQL - NO DATA" | |
| } | |
| Set val = rs.Value | |
| $$$TRACE("Val: " _ val) | |
| $$$TRACE("Releasing lock") | |
| LOCK -^Lock.RefData("ref")#"S" | |
| Quit val | |
| ]]></Implementation> | |
| </Method> | |
| </Class> | |
| <Class name="Lock.Production"> | |
| <ProcedureBlock>0</ProcedureBlock> | |
| <Super>Ens.Production</Super> | |
| <TimeChanged>67653,52011.8558595</TimeChanged> | |
| <TimeCreated>67634,37613.0837449</TimeCreated> | |
| <XData name="ProductionDefinition"> | |
| <Data><![CDATA[ | |
| <Production Name="Lock.Production" TestingEnabled="true" LogGeneralTraceEvents="true"> | |
| <Description></Description> | |
| <ActorPoolSize>1</ActorPoolSize> | |
| <Item Name="Lock.BO" Category="" ClassName="Lock.BO" PoolSize="1" Enabled="true" Foreground="false" Comment="" LogTraceEvents="true" Schedule=""> | |
| </Item> | |
| <Item Name="Router" Category="" ClassName="EnsLib.MsgRouter.RoutingEngine" PoolSize="1" Enabled="true" Foreground="false" Comment="" LogTraceEvents="true" Schedule=""> | |
| <Setting Target="Host" Name="BusinessRuleName">Lock.Router</Setting> | |
| <Setting Target="Host" Name="RuleLogging">a</Setting> | |
| </Item> | |
| <Item Name="Lock.BS" Category="" ClassName="Lock.BS" PoolSize="1" Enabled="false" Foreground="false" Comment="" LogTraceEvents="true" Schedule=""> | |
| <Setting Target="Host" Name="Target">Router</Setting> | |
| <Setting Target="Adapter" Name="CallInterval">1</Setting> | |
| </Item> | |
| </Production> | |
| ]]></Data> | |
| </XData> | |
| </Class> | |
| <Class name="Lock.RefData"> | |
| <Super>%Persistent</Super> | |
| <TimeChanged>67634,40429.3865459</TimeChanged> | |
| <TimeCreated>67634,40296.0801077</TimeCreated> | |
| <Property name="Value"> | |
| </Property> | |
| <Storage name="Default"> | |
| <Type>%Storage.Persistent</Type> | |
| <DataLocation>^Lock.RefDataD</DataLocation> | |
| <DefaultData>RefDataDefaultData</DefaultData> | |
| <IdLocation>^Lock.RefDataD</IdLocation> | |
| <IndexLocation>^Lock.RefDataI</IndexLocation> | |
| <StreamLocation>^Lock.RefDataS</StreamLocation> | |
| <ExtentSize>1</ExtentSize> | |
| <Data name="RefDataDefaultData"> | |
| <Structure>listnode</Structure> | |
| <Subscript/> | |
| <Value name="1"> | |
| <Value>%%CLASSNAME</Value> | |
| </Value> | |
| <Value name="2"> | |
| <Value>Value</Value> | |
| </Value> | |
| </Data> | |
| <Property name="%%CLASSNAME"> | |
| <Selectivity>0.0001%</Selectivity> | |
| <OutlierSelectivity>.999999:</OutlierSelectivity> | |
| <AverageFieldSize>2</AverageFieldSize> | |
| </Property> | |
| <Property name="%%ID"> | |
| <Selectivity>1</Selectivity> | |
| <AverageFieldSize>3</AverageFieldSize> | |
| </Property> | |
| <Property name="Value"> | |
| <Selectivity>0.0001%</Selectivity> | |
| <OutlierSelectivity>.999999:"2026-03-05 11:13:37.000"</OutlierSelectivity> | |
| <AverageFieldSize>25</AverageFieldSize> | |
| </Property> | |
| <SQLMap name="IDKEY"> | |
| <BlockCount>-4</BlockCount> | |
| </SQLMap> | |
| </Storage> | |
| </Class> | |
| <Class name="Lock.Router"> | |
| <Description> | |
| </Description> | |
| <Super>Ens.Rule.Definition</Super> | |
| <TimeChanged>67653,51746.24096</TimeChanged> | |
| <TimeCreated>67634,38566.4561684</TimeCreated> | |
| <Parameter name="RuleAssistClass"> | |
| <Default>EnsLib.MsgRouter.RuleAssist</Default> | |
| </Parameter> | |
| <XData name="RuleDefinition"> | |
| <XMLNamespace>http://www.intersystems.com/rule</XMLNamespace> | |
| <Data><![CDATA[ | |
| <ruleDefinition alias="" context="EnsLib.MsgRouter.RoutingEngine" production="Lock.Production"> | |
| <variable name="refval"></variable> | |
| <ruleSet name="" effectiveBegin="" effectiveEnd=""> | |
| <assign property="@refval" value="GetRefData()"></assign> | |
| <trace value="@refval"></trace> | |
| <return></return> | |
| </ruleSet> | |
| </ruleDefinition> | |
| ]]></Data> | |
| </XData> | |
| </Class> | |
| </Export> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment