Description
This is the method that contains the call to the specific method in the appropriate class to perform the request.
This method should be extended on the specific daemon level.
In order to have a proper logging of the errors/warnings you get from the business method that is used for processing the work, you need to fill in tPassMessages temp-table parameter, as a copy of tFcMessages from the called business component.
Parameters
| iiDaemonQueueId | input | integer | ID of the daemon queue record that indicates the work that needs to be done. |
| olSuccess | output | logical | Was the operation successful? |
| oiReturnStatus | output | integer | Return status of the method. |
Internal usage
unused
program code (program/beventdaemonprocessor.p)
<ANCESTOR-CODE>
<M-1 run GetDocument
(input iiDaemonQueueId (iiDaemonQueueId),
output vmEvent (omDocument),
output viDestinationId (oiDestinationId),
output vcBusComponentName (ocBusComponentName),
output vcObjectId (ocObjectId),
output viFcReturnSuper (oiReturnStatus)) in BEventDaemonQueue>
if viFcReturnSuper < 0
then do :
vcMessage = substitute(#T-73'Unable to read the document containing the XML representation of the object. (work item &1)':255(6638)T-73#,string(iiDaemonQueueId)).
<M-40 run SetMessage
(input vcMessage (icMessage),
input '' (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'D' (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'blf-80117':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BEventDaemonProcessor>
<M-6 run SetMessageInDaemonLog
(input vcMessage (icMessage),
output viFcReturnSuper (oiReturnStatus)) in BEventDaemonProcessor>
assign olSuccess = false.
oiReturnStatus = 0.
return.
end.
/* if event is empty, it is not needed to send the event */
if get-size(vmEvent) = 0
then do:
assign olSuccess = true.
oiReturnStatus = 0.
return.
end.
/*get the event destination info*/
<Q-7 run EventDestination (all) (Read) (Cache)
(input viDestinationId, (DestinationId)
output dataset tqEventDestination) in BEventDestination >
find first tqEventDestination where
tqEventDestination.tiEventDestination_ID = viDestinationId no-error.
if not available tqEventDestination
then do:
assign vcMessage = substitute(trim(#T-10'Unable to get event destination information. (work item &1)':255(9036)T-10#),string(iiDaemonQueueId))
olSuccess = false
oiReturnStatus = 0.
<M-52 run SetMessage
(input vcMessage (icMessage),
input '' (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'D' (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'blf-426385':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BEventDaemonProcessor>
<M-8 run SetMessageInDaemonLog
(input vcMessage (icMessage),
output viFcReturnSuper (oiReturnStatus)) in BEventDaemonProcessor>
return.
end.
if tqEventDestination.tcEventDestinationType = {&EVENTDESTINATIONTYPE-DIRECTAPPSERVER}
then do:
if tqEventDestination.tcEventDestinationASName = {&EVENTDESTINATION-DEFAULTCONN} or
tqEventDestination.tcEventDestinationASProc = {&EVENTDESTINATION-DEFAULTPROC}
then do:
assign vcFile = search ("server.xml":U)
vhFcComponent = ?.
<M-11 run MainBlock () in XML>
assign vhXMLhandle = vhFcComponent.
<M-12 run ReadXML
(input vcFile (icXMLFile),
input 'appServerConnection':U (icStartTag),
output tNodesEDP (tNodes),
output viFcReturnSuper (oiReturnStatus)) in XML>
run gipr_DeleteProcedure in vhXMLhandle.
delete procedure vhXMLHandle.
if viFcReturnSuper < 0
then do:
assign vcMessage = trim(#T-15'Unable to read the server.xml for the right appServerConnection.':255(9037)T-15#)
olSuccess = false
oiReturnStatus = 0.
<M-89 run SetMessage
(input vcMessage (icMessage),
input '' (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'D' (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'blf-160136':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BEventDaemonProcessor>
<M-16 run SetMessageInDaemonLog
(input vcMessage (icMessage),
output viFcReturnSuper (oiReturnStatus)) in BEventDaemonProcessor>
return.
end.
find first tNodesEDP where
trim(tNodesEDP.tcNodeName) = "serviceInstanceKey":U and
trim(tNodesEDP.tcNodeValue) = "Publish":U no-error.
if available tNodesEDP
then do:
assign viFcCount1 = tNodesEDP.tiNodeParentId.
if tqEventDestination.tcEventDestinationASName = {&EVENTDESTINATION-DEFAULTCONN}
then do:
find first tNodesEDP where
tNodesEDP.tiNodeParentId = viFcCount1 and
trim(tNodesEDP.tcNodeName) = "appServiceURL":U no-error.
if available tNodesEDP
then assign tqEventDestination.tcEventDestinationASName = trim(tNodesEDP.tcNodeValue).
end.
if tqEventDestination.tcEventDestinationASProc = {&EVENTDESTINATION-DEFAULTPROC}
then do:
find first tNodesEDP where
tNodesEDP.tiNodeParentId = viFcCount1 and
trim(tNodesEDP.tcNodeName) = "procedureName":U no-error.
if available tNodesEDP
then assign tqEventDestination.tcEventDestinationASProc = trim(tNodesEDP.tcNodeValue).
end.
end.
else do:
assign vcMessage = trim(#T-18'Unable to read the server.xml for an appServerConnection of type Publish.':255(9038)T-18#)
olSuccess = false
oiReturnStatus = 0.
<M-61 run SetMessage
(input vcMessage (icMessage),
input '' (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'D' (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'blf-814215':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BEventDaemonProcessor>
<M-17 run SetMessageInDaemonLog
(input vcMessage (icMessage),
output viFcReturnSuper (oiReturnStatus)) in BEventDaemonProcessor>
return.
end.
end.
/* connect to the appserver */
if vhAppserver = ?
then create server vhAppserver.
vhAppserver:connect ("-URL ":U + tqEventDestination.tcEventDestinationASName) no-error.
if not vhAppserver:connected()
then do:
assign vcMessage = substitute(trim(#T-14'Could not connect to appserver. Please check the connection URL (&1).':255(9053)T-14#),tqEventDestination.tcEventDestinationASName)
olSuccess = false
oiReturnStatus = 0.
<M-60 run SetMessage
(input vcMessage (icMessage),
input '' (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'D' (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'blf-492097':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BEventDaemonProcessor>
<M-19 run SetMessageInDaemonLog
(input vcMessage (icMessage),
output viFcReturnSuper (oiReturnStatus)) in BEventDaemonProcessor>
delete object vhAppServer.
vhAppServer = ?.
return.
end.
/*fill the input dataset*/
create dataset vhDS in widget-pool "non-persistent".
vhDS:name = "event" + string(iiDaemonQueueId).
vlReadOK = vhDS:Read-xml("memptr",vmEvent,"empty",?,?,?,"STRICT") no-error.
if not vlReadOK
or error-status:error
or error-status:num-messages > 0
then do:
do viFcCount1 = 1 to error-status:num-messages:
if viFcCount1 > 1
then assign vcMessage = vcMessage + chr(2).
assign vcMessage = vcMessage + error-status:get-message(viFcCount1).
end.
olSuccess = false.
oiReturnStatus = 0.
<M-76 run SetMessage
(input vcMessage (icMessage),
input '' (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'D' (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'blf-79594':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BEventDaemonProcessor>
<M-79 run SetMessageInDaemonLog
(input vcMessage (icMessage),
output viFcReturnSuper (oiReturnStatus)) in BEventDaemonProcessor>
return.
end.
/* Get EnityCode and DomainCode from the tContextInfo */
assign vcEntityCode = ""
vcDomainCode = "".
if valid-handle (vhDS)
then do:
assign vhtContextInfo = vhDS::tContextInfo no-error.
if valid-handle (vhtContextInfo)
then if vhDS::tContextInfo:FIND-FIRST()
then assign vcEntityCode = vhDS::tContextInfo::tcCompanyCode
vcEventActivityCode = vhDS::tContextInfo::tcActivityCode
vcEventUser = (if vhDS::tContextInfo::tcOriginator begins "user "
then substring(vhDS::tContextInfo::tcOriginator,6,-1,"CHARACTER")
else "")
no-error.
<Q-36 run CompanyByCompanyCodeDomainCode (all) (Read) (NoCache)
(input ?, (CompanyId)
input vcEntityCode, (CompanyCode)
input ?, (DomainCode)
input ?, (DomainId)
input ?, (CompanyIsActive)
output dataset tqCompanyByCompanyCodeDomainCode) in BCompany>
find first tqCompanyByCompanyCodeDomainCode no-error.
if available tqCompanyByCompanyCodeDomainCode
then assign vcDomainCode = tqCompanyByCompanyCodeDomainCode.tcDomainCode.
end.
<Q-29 run System (all) (Read) (NoCache)
(input ?, (LanguageID)
output dataset tqSystem) in BSystem >
find first tqSystem no-error.
/*fill the context dataset*/
empty temp-table ttContext.
create ttContext.
assign ttContext.propertyQualifier = "QAD":U
ttContext.propertyName = "sessionId":U
ttContext.propertyValue = vcGlobalSessionId.
create ttContext.
assign ttContext.propertyQualifier = "CBF":U
ttContext.propertyName = "componentName":U
ttContext.propertyValue = vcBusComponentName.
create ttContext.
assign ttContext.propertyQualifier = "QAD":U
ttContext.propertyName = "datasetInName":U
ttContext.propertyValue = vcBusComponentName.
create ttContext.
assign ttContext.propertyQualifier = "QAD":U
ttContext.propertyName = "datasetInOutName":U
ttContext.propertyValue = "":U.
create ttContext.
assign ttContext.propertyQualifier = "QAD":U
ttContext.propertyName = "datasetOutName":U
ttContext.propertyValue = "":U.
create ttContext.
assign ttContext.propertyQualifier = "QAD":U
ttContext.propertyName = "entity":U
ttContext.propertyValue = vcEntityCode.
create ttContext.
assign ttContext.propertyQualifier = "QAD":U
ttContext.propertyName = "domain":U
ttContext.propertyValue = vcDomainCode.
if vcEventActivityCode <> ""
then do:
create ttContext.
assign ttContext.propertyQualifier = "QAD":U
ttContext.propertyName = "BusinessEvent":U
ttContext.propertyValue = vcEventActivityCode.
end.
if vcEventUser <> ""
then do:
vhDS::tContextInfo::tcOriginator = "".
create ttContext.
assign ttContext.propertyQualifier = "QAD":U
ttContext.propertyName = "userId":U
ttContext.propertyValue = vcEventUser.
<Q-9 run UserByUsrLogin (all) (Read) (NoCache)
(input vcEventUser, (UsrLogin)
output dataset tqUserByUsrLogin) in BUser >
find first tqUserByUsrLogin where tqUserByUsrLogin.tcUsrLogin = vcEventUser no-error.
if available tqUserByUsrLogin
then if tqUserByUsrLogin.tcUsrMailAddress <> ""
then do:
create ttContext.
assign ttContext.propertyQualifier = "QAD":U
ttContext.propertyName = "Email":U
ttContext.propertyValue = tqUserByUsrLogin.tcUsrMailAddress.
end.
end.
/* For the first implementation, both methodName and programName have
fixed default values. These are recognized by QXO */
create ttContext.
assign ttContext.propertyQualifier = "QAD":U
ttContext.propertyName = "programName":U
ttContext.propertyValue = "com/qad/qxtend/si/BusinessObjectManager.p":U.
create ttContext.
assign ttContext.propertyQualifier = "QAD":U
ttContext.propertyName = "methodName":U
ttContext.propertyValue = "createBusinessObjectMessage":U.
create ttContext.
assign ttContext.propertyQualifier = "QXO":U
ttContext.propertyName = "sourceApplication":U
ttContext.propertyValue = (if available tqSystem
then tqSystem.tcSystApplicationId
else "":U).
assign vhSessionContext = dataset dsSessionContext:handle.
/*execute the procedure on the appserver*/
if not tqEventDestination.tcEventDestinationASProc matches "*.p":U and
not tqEventDestination.tcEventDestinationASProc matches "*.r":U
then do:
assign tqEventDestination.tcEventDestinationASProc = tqEventDestination.tcEventDestinationASProc + ".p":U.
end.
run value(tqEventDestination.tcEventDestinationASProc)
on server vhAppserver (input-output dataset-handle vhSessionContext by-reference,
output dataset-handle vhExceptions by-reference,
input dataset-handle vhDS by-reference,
input-output dataset-handle vhInOut by-reference,
output dataset-handle vhOut by-reference) no-error.
if error-status:error
then do:
assign vcMessage = substitute(trim(#T-23'An error occured when trying to run procedure (&1) on appserver (&2).':255(9054)T-23#),
tqEventDestination.tcEventDestinationASProc,
tqEventDestination.tcEventDestinationASName)
olSuccess = false
oiReturnStatus = 0.
<M-50 run SetMessage
(input vcMessage (icMessage),
input '' (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'D' (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'blf-810327':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BEventDaemonProcessor>
<M-22 run SetMessageInDaemonLog
(input vcMessage (icMessage),
output viFcReturnSuper (oiReturnStatus)) in BEventDaemonProcessor>
do viFcCount1 = 1 to error-status:num-messages:
assign vcMessage = error-status:get-message(viFcCount1).
<M-95 run SetMessage
(input vcMessage (icMessage),
input '' (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'D' (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'blf-824494':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BEventDaemonProcessor>
<M-30 run SetMessageInDaemonLog
(input vcMessage (icMessage),
output viFcReturnSuper (oiReturnStatus)) in BEventDaemonProcessor>
end.
return.
end.
/*evaluate the content of dsExceptions*/
/* First check whether there is a record in the exception table */
assign vhTable = vhExceptions:get-buffer-handle("temp_err_msg":U) no-error.
assign olSuccess = true.
if valid-handle(vhTable)
then do:
create query vhQuery in widget-pool "non-persistent".
vhQuery:forward-only = yes.
vhQuery:add-buffer(vhTable).
vhQuery:query-prepare("for each " + vhTable:table).
vhQuery:query-open().
vhQuery:get-first(no-lock).
if not vhQuery:Query-Off-End
then do :
olSuccess = false.
do while not vhQuery:Query-Off-End :
assign vcMessage = #T-26'The service interface returned the following error:':70(8160)T-26# + chr(10) +
"tt_msg_sev = " + vhTable::tt_msg_sev + chr(10) +
"tt_msg_nbr = " + vhTable::tt_msg_nbr + chr(10) +
"tt_msg_desc = " + vhTable::tt_msg_desc + chr(10) +
"tt_msg_data = " + vhTable::tt_msg_data + chr(10) +
"tt_msg_context = " + vhTable::tt_msg_context + chr(10) +
"tt_msg_field = " + vhTable::tt_msg_field + chr(10) +
"tt_msg_index = " + vhTable::tt_msg_index.
<M-75 run SetMessage
(input vcMessage (icMessage),
input '' (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'D' (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'blf-149467':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BEventDaemonProcessor>
<M-28 run SetMessageInDaemonLog
(input vcMessage (icMessage),
output viFcReturnSuper (oiReturnStatus)) in BEventDaemonProcessor>
vhQuery:get-next(no-lock).
end.
end.
vhQuery:query-close().
delete object vhQuery.
end.
end. /*if tqEventDestination.tcEventDestinationType = {&EVENTDESTINATIONTYPE-DIRECTAPPSERVER}*/
else if tqEventDestination.tcEventDestinationType = {&EVENTDESTINATIONTYPE-TODIR}
then do:
assign vcDir = replace(tqEventDestination.tcEventDestinationDir,"~\","/")
vcDir = vcDir +
(if vcDir matches "*/"
then ""
else "/") +
vcBusComponentName.
OS-CREATE-DIR value(vcDir).
viOSError = OS-ERROR.
if viOSError <> 0
then do:
assign vcMessage = substitute(trim(#T-21'Could not create directory &1 on server.':255(9039)T-21#),vcDir)
olSuccess = false
oiReturnStatus = 0.
<M-54 run SetMessage
(input vcMessage (icMessage),
input '' (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'D' (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'blf-678571':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BEventDaemonProcessor>
<M-20 run SetMessageInDaemonLog
(input vcMessage (icMessage),
output viFcReturnSuper (oiReturnStatus)) in BEventDaemonProcessor>
return.
end.
output stream sStrOut to value(vcDir + "/":U + vcObjectId + ".xml":U).
output stream sStrOut close.
file-info:file-name = vcDir + "/":U + vcObjectId + ".xml":U.
if file-info:file-type = ?
then do:
assign vcMessage = substitute(trim(#T-32'Could not create file &1.':255(9375)T-32#),vcDir + "/":U + vcObjectId + ".xml":U)
olSuccess = false
oiReturnStatus = 0.
<M-84 run SetMessage
(input vcMessage (icMessage),
input '' (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'D' (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'blf-54474':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BEventDaemonProcessor>
<M-31 run SetMessageInDaemonLog
(input vcMessage (icMessage),
output viFcReturnSuper (oiReturnStatus)) in BEventDaemonProcessor>
return.
end.
copy-lob from vmEvent to file vcDir + "/":U + vcObjectId + ".xml":U.
assign olSuccess = true.
end. /*else if tqEventDestination.tcEventDestinationType = {&EVENTDESTINATIONTYPE-TODIR}*/
finally:
set-size(vmEvent) = 0.
if vhAppServer <> ?
then do:
vhAppserver:disconnect().
delete object vhAppServer.
end.
if valid-handle (vhDS)
then delete object vhDS.
if valid-handle (vhExceptions)
then delete object vhExceptions.
end finally.