project BLF > class BXmlDaemon > method ApiMonitorXml
Description
Api-method to monitor the fcDaemonQueue records.
Parameters
ilIncludeWaiting | input | logical | Include DaemonQueue records of DaemonQueueStatus Waiting |
ilIncludeInProcess | input | logical | Include DaemonQueue records of DaemonQueueStatus InProcess |
ilIncludeProcessedOk | input | logical | Include DaemonQueue records of DaemonQueueStatus Processed-Ok |
ilIncludeProcessedErr | input | logical | Include DaemonQueue records of DaemonQueueStatus Processed-Err |
icFileOwnerFilter | input | character | |
tfcDaemonMonitor | output | temp-table | |
tXmlDaemonQueueMonitor | output | temp-table | |
tfcDaemonQueueLogMonitor | output | temp-table | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
unused
program code (program3/bxmldaemon.p)
/* Find information about the Daemon */
<Q-1 run DaemonInfo (all) (Read) (NoCache)
(input ?, (DaemonId)
input vcFcDaemonName, (DaemonName)
input ?, (DaemonStatus)
input ?, (DaemonStatusDiffersFrom)
output dataset tqDaemonInfo) in BBaseDaemon >
find first tqDaemonInfo where
tqDaemonInfo.tcDaemonName = vcFcDaemonName
no-error.
if not available tqDaemonInfo
then do:
<M-2 run SetMessage
(input trim(#T-48'This daemon has not yet been configured. You must configure the daemon before it can be started or monitored.':255(50)T-48#) (icMessage),
input '' (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'E' (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'BLF-6':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBaseDaemon>
assign oiReturnStatus = -1.
return.
end.
/* Clear the output temp-tables */
empty temp-table tfcDaemonMonitor.
empty temp-table tXmlDaemonQueueMonitor.
empty temp-table tfcDaemonQueueLogMonitor.
/* Fill output table for fcDaemon */
create tfcDaemonMonitor.
buffer-copy tqDaemonInfo to tfcDaemonMonitor.
assign tfcDaemonMonitor.tiDaemonQueueWaiting = 0.
/* Read the queue */
if ilIncludeInProcess and
ilIncludeProcessedErr and
ilIncludeProcessedOk and
ilIncludeWaiting
then do:
/* Read the entire queue */
<Q-88 run XmlDaemonQueueByDaemonID (all) (Read) (NoCache)
(input tqDaemonInfo.tiDaemonId, (DaemonID)
input ?, (DaemonQueueStatus)
input icFileOwnerFilter, (DaemonQueueFileOwner)
output dataset tqXmlDaemonQueueByDaemonID) in BXmlDaemonQueue>
for each tqXmlDaemonQueueByDaemonID where
tqXmlDaemonQueueByDaemonID.tiDaemonId = tqDaemonInfo.tiDaemonId:
create tXmlDaemonQueueMonitor.
buffer-copy tqXmlDaemonQueueByDaemonID to tXmlDaemonQueueMonitor.
if tqXmlDaemonQueueByDaemonID.tcDaemonQueueStatus = {&DAEMONQUEUESTATUS-WAITING}
then assign tfcDaemonMonitor.tiDaemonQueueWaiting = tfcDaemonMonitor.tiDaemonQueueWaiting + 1.
else
if tqXmlDaemonQueueByDaemonID.tcDaemonQueueStatus = {&DAEMONQUEUESTATUS-PROCESSEDERR}
then do:
<Q-75 run DaemonQueueLogByDaemonQueueId (all) (Read) (NoCache)
(input tqXmlDaemonQueueByDaemonID.tiDaemonQueueId, (DaemonQueueId)
output dataset tqDaemonQueueLogByDaemonQueueId) in BBaseDaemonQueue>
for each tqDaemonQueueLogByDaemonQueueId where
tqDaemonQueueLogByDaemonQueueId.tiDaemonQueueId = tqXmlDaemonQueueByDaemonID.tiDaemonQueueId:
create tfcDaemonQueueLogMonitor.
buffer-copy tqDaemonQueueLogByDaemonQueueId to tfcDaemonQueueLogMonitor.
end.
end.
end.
end.
else do:
/* Read Waiting records */
<Q-85 run XmlDaemonQueueByDaemonID (all) (Read) (NoCache)
(input tqDaemonInfo.tiDaemonId, (DaemonID)
input {&DAEMONQUEUESTATUS-WAITING}, (DaemonQueueStatus)
input icFileOwnerFilter, (DaemonQueueFileOwner)
output dataset tqXmlDaemonQueueByDaemonID) in BXmlDaemonQueue>
for each tqXmlDaemonQueueByDaemonID where
tqXmlDaemonQueueByDaemonID.tiDaemonId = tqDaemonInfo.tiDaemonId and
tqXmlDaemonQueueByDaemonID.tcDaemonQueueStatus = {&DAEMONQUEUESTATUS-WAITING}:
if ilIncludeWaiting
then do:
create tXmlDaemonQueueMonitor.
buffer-copy tqXmlDaemonQueueByDaemonID to tXmlDaemonQueueMonitor.
end.
assign tfcDaemonMonitor.tiDaemonQueueWaiting = tfcDaemonMonitor.tiDaemonQueueWaiting + 1.
end.
/* Read In Process records if necessary */
if ilIncludeInProcess
then do:
<Q-84 run XmlDaemonQueueByDaemonID (all) (Read) (NoCache)
(input tqDaemonInfo.tiDaemonId, (DaemonID)
input {&DAEMONQUEUESTATUS-INPROCESS}, (DaemonQueueStatus)
input icFileOwnerFilter, (DaemonQueueFileOwner)
output dataset tqXmlDaemonQueueByDaemonID) in BXmlDaemonQueue>
for each tqXmlDaemonQueueByDaemonID where
tqXmlDaemonQueueByDaemonID.tiDaemonId = tqDaemonInfo.tiDaemonId and
tqXmlDaemonQueueByDaemonID.tcDaemonQueueStatus = {&DAEMONQUEUESTATUS-INPROCESS}:
create tXmlDaemonQueueMonitor.
buffer-copy tqXmlDaemonQueueByDaemonID to tXmlDaemonQueueMonitor.
end.
end.
/* Read Processed OK records if necessary */
if ilIncludeProcessedOk
then do:
<Q-56 run XmlDaemonQueueByDaemonID (all) (Read) (NoCache)
(input tqDaemonInfo.tiDaemonId, (DaemonID)
input {&DAEMONQUEUESTATUS-PROCESSEDOK}, (DaemonQueueStatus)
input icFileOwnerFilter, (DaemonQueueFileOwner)
output dataset tqXmlDaemonQueueByDaemonID) in BXmlDaemonQueue>
for each tqXmlDaemonQueueByDaemonID where
tqXmlDaemonQueueByDaemonID.tiDaemonId = tqDaemonInfo.tiDaemonId and
tqXmlDaemonQueueByDaemonID.tcDaemonQueueStatus = {&DAEMONQUEUESTATUS-PROCESSEDOK}:
create tXmlDaemonQueueMonitor.
buffer-copy tqXmlDaemonQueueByDaemonID to tXmlDaemonQueueMonitor.
end.
end.
/* Read Processed Error records if necessary */
if ilIncludeProcessedErr
then do:
<Q-32 run XmlDaemonQueueByDaemonID (all) (Read) (NoCache)
(input tqDaemonInfo.tiDaemonId, (DaemonID)
input {&DAEMONQUEUESTATUS-PROCESSEDERR}, (DaemonQueueStatus)
input icFileOwnerFilter, (DaemonQueueFileOwner)
output dataset tqXmlDaemonQueueByDaemonID) in BXmlDaemonQueue>
for each tqXmlDaemonQueueByDaemonID where
tqXmlDaemonQueueByDaemonID.tiDaemonId = tqDaemonInfo.tiDaemonId and
tqXmlDaemonQueueByDaemonID.tcDaemonQueueStatus = {&DAEMONQUEUESTATUS-PROCESSEDERR}:
create tXmlDaemonQueueMonitor.
buffer-copy tqXmlDaemonQueueByDaemonID to tXmlDaemonQueueMonitor.
<Q-44 run DaemonQueueLogByDaemonQueueId (all) (Read) (NoCache)
(input tqXmlDaemonQueueByDaemonID.tiDaemonQueueId, (DaemonQueueId)
output dataset tqDaemonQueueLogByDaemonQueueId) in BBaseDaemonQueue>
for each tqDaemonQueueLogByDaemonQueueId where
tqDaemonQueueLogByDaemonQueueId.tiDaemonQueueId = tqXmlDaemonQueueByDaemonID.tiDaemonQueueId:
create tfcDaemonQueueLogMonitor.
buffer-copy tqDaemonQueueLogByDaemonQueueId to tfcDaemonQueueLogMonitor.
end.
end.
end.
end.
Sample code: how to call this method through RPCRequestService (QXtend Inbound)
define temp-table ttContext no-undo
field propertyQualifier as character
field propertyName as character
field propertyValue as character
index entityContext is primary unique
propertyQualifier
propertyName
index propertyQualifier
propertyQualifier.
define dataset dsContext for ttContext.
define variable vhContextDS as handle no-undo.
define variable vhExceptionDS as handle no-undo.
define variable vhServer as handle no-undo.
define variable vhInputDS as handle no-undo.
define variable vhInputOutputDS as handle no-undo.
define variable vhOutputDS as handle no-undo.
define variable vhParameter as handle no-undo.
/* Create context */
create ttContext.
assign ttContext.propertyName = "programName"
ttContext.propertyValue = "BXmlDaemon".
create ttContext.
assign ttContext.propertyName = "methodName"
ttContext.propertyValue = "ApiMonitorXml".
create ttContext.
assign ttContext.propertyName = "applicationId"
ttContext.propertyValue = "fin".
create ttContext.
assign ttContext.propertyName = "entity"
ttContext.propertyValue = "1000".
create ttContext.
assign ttContext.propertyName = "userName"
ttContext.propertyValue = "mfg".
create ttContext.
assign ttContext.propertyName = "password"
ttContext.propertyValue = "".
/* Create input dataset */
create dataset vhInputDS.
vhInputDS:read-xmlschema("file", "xml/bxmldaemon.apimonitorxml.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tParameterI").
vhParameter:buffer-create().
assign vhParameter::ilIncludeWaiting = <parameter value>
vhParameter::ilIncludeInProcess = <parameter value>
vhParameter::ilIncludeProcessedOk = <parameter value>
vhParameter::ilIncludeProcessedErr = <parameter value>
vhParameter::icFileOwnerFilter = <parameter value>.
/* Connect the AppServer */
create server vhServer.
vhServer:connect("-URL <appserver-url>").
if not vhServer:connected()
then do:
message "Could not connect AppServer" view-as alert-box error title "Error".
return.
end.
/* Run */
assign vhContextDS = dataset dsContext:handle.
run program/rpcrequestservice.p on vhServer
(input-output dataset-handle vhContextDS by-reference,
output dataset-handle vhExceptionDS,
input dataset-handle vhInputDS by-reference,
input-output dataset-handle vhInputOutputDS by-reference,
output dataset-handle vhOutputDS).
/* Handle output however you want, in this example, we dump it to xml */
if valid-handle(vhExceptionDS)
then vhExceptionDS:write-xml("file", "Exceptions.xml", true).
if valid-handle(vhOutputDS)
then vhOutputDS:write-xml("file", "Output.xml", true).
/* Cleanup */
vhServer:disconnect().
assign vhServer = ?.
if valid-handle(vhInputDS)
then delete object vhInputDS.
if valid-handle(vhOutputDS)
then delete object vhOutputDS.
if valid-handle(vhExceptionDS)
then delete object vhExceptionDS.