Skip to content

Instantly share code, notes, and snippets.

@eduard93
Created July 20, 2023 09:37
Show Gist options
  • Save eduard93/df1a873ef6ed63b6a723185d709eb35d to your computer and use it in GitHub Desktop.
Save eduard93/df1a873ef6ed63b6a723185d709eb35d to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25" zv="IRIS for Windows (x86-64) 2022.1 (Build 209U)" ts="2023-07-20 12:35:39">
<Class name="in.BO">
<Super>Ens.BusinessOperation</Super>
<TimeChanged>66675,43352.7129041</TimeChanged>
<TimeCreated>66675,42686.1278222</TimeCreated>
<Parameter name="INVOCATION">
<Default>InProc</Default>
</Parameter>
<Property name="Counter">
<Type>%Integer</Type>
<InitialExpression>0</InitialExpression>
</Property>
<Method name="OnMessage">
<Description>
This is the default message handler. All request types not declared in the message map are delivered here</Description>
<FormalSpec>pRequest:Ens.Request,*pResponse:Ens.StringResponse</FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
Set pResponse = ##class(Ens.StringResponse).%New($i(i%Counter))
Quit $$$OK
]]></Implementation>
</Method>
</Class>
<Class name="in.BOQueue">
<Super>in.BO</Super>
<TimeChanged>66675,43468.2684286</TimeChanged>
<TimeCreated>66675,43468.2684286</TimeCreated>
<Parameter name="INVOCATION">
<Default>Queue</Default>
</Parameter>
</Class>
<Class name="in.BS">
<Super>Ens.BusinessService</Super>
<TimeChanged>66675,42712.8815343</TimeChanged>
<TimeCreated>66675,42712.8815343</TimeCreated>
</Class>
<Class name="in.Production">
<Super>Ens.Production</Super>
<TimeChanged>66675,43504.6576868</TimeChanged>
<TimeCreated>66675,42742.282125</TimeCreated>
<Method name="OnStart">
<ClassMethod>1</ClassMethod>
<FormalSpec>pTimeStarted:%String</FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
Set status = $$$OK
Set restApp="/test123"
Set startNSP = $namespace
$$$LOGINFO("OnStart - creating REST end point if it does not exist: "_restApp)
New $NAMESPACE
Set $namespace="%SYS"
If '##class(Security.Applications).Exists(restApp) {
Set properties("NameSpace") = startNSP
Set properties("DispatchClass") = "in.REST"
Set properties("CookiePath") = restApp_"/"
Set properties("Description") = "Counter API"
Set properties("MatchRoles") = ":%All"
Set properties("AutheEnabled") = 64
Set properties("Enabled")=1
Set status = ##class(Security.Applications).Create(restApp, .properties)
}
Set $namespace=startNSP
$$$LOGINFO("Finished OnStart")
Quit status
]]></Implementation>
</Method>
<XData name="ProductionDefinition">
<Data><![CDATA[
<Production Name="in.Production" TestingEnabled="true" LogGeneralTraceEvents="false">
<Description></Description>
<ActorPoolSize>2</ActorPoolSize>
<Item Name="in.BS" Category="" ClassName="in.BS" PoolSize="1" Enabled="true" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
</Item>
<Item Name="in.BO" Category="" ClassName="in.BO" PoolSize="1" Enabled="true" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
</Item>
<Item Name="in.BOQueue" Category="" ClassName="in.BOQueue" PoolSize="1" Enabled="true" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
</Item>
</Production>
]]></Data>
</XData>
</Class>
<Class name="in.REST">
<IncludeCode>Ensemble</IncludeCode>
<Super>%CSP.REST</Super>
<TimeChanged>66675,44943.3561387</TimeChanged>
<TimeCreated>66675,42816.748585</TimeCreated>
<Parameter name="CHARSET">
<Default>utf-8</Default>
</Parameter>
<Parameter name="HandleCorsRequest">
<Default>true</Default>
</Parameter>
<Parameter name="CONTENTTYPE">
<Expression>..#CONTENTTYPEJSON</Expression>
</Parameter>
<XData name="UrlMap">
<XMLNamespace>http://www.hmtsapi.com/urlmap</XMLNamespace>
<Data><![CDATA[
<Routes>
<Route Url="/dispatch/:queue" Method="GET" Call="dispatch"/>
</Routes>
]]></Data>
</XData>
<Method name="dispatch">
<Description>
GET http://localhost:52773/test123/dispatch/0</Description>
<ClassMethod>1</ClassMethod>
<FormalSpec>queue:%Boolean=$$$NO</FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
try {
zw $$$EnsJobLocal
#dim sc As %Status = $$$OK
#dim %request As %CSP.Request
#dim response As Ens.StringResponse
#dim service As Ens.BusinessService
do ..getBS(.service)
set bo = $case(queue, $$$YES: "in.BOQueue", :"in.BO")
$$$TOE(sc, service.SendRequestSync(bo,##class(Ens.Request).%New(),.response))
w {
"Count":(response.StringValue),
"Job":(+$job)
}.%ToJSON()
//zw $$$EnsJobLocal
}
catch(ex){
Set sc = ex.AsStatus()
}
quit sc
]]></Implementation>
</Method>
<Method name="getBS">
<ClassMethod>1</ClassMethod>
<FormalSpec>*service</FormalSpec>
<ReturnType>Ens.BusinessService</ReturnType>
<Implementation><![CDATA[
#dim %session As %CSP.Session
set %session.Preserve = $$$YES
set $$$EnsInProcPersist = $$$YES
if '$data(%JDBCGateway("service")) {
$$$TOE(sc, ##class(Ens.Director).CreateBusinessService("in.BS", .service))
set %JDBCGateway("service") = service
} else {
set service = %JDBCGateway("service")
}
]]></Implementation>
</Method>
</Class>
</Export>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment