Question
· Jul 5, 2022

Shutdown Ensemble Business Service upon Warning in the Event Log

Hello,

We have a scenario where a bad message(With control character in some fields) is coming frequently in our Standard HL7 Business Service.

I do see the process gets shut down because of E=D action code. I also see the service logging an "Warning" about the bad message. But service is not shutting down.

Is there a way to handle this error right at the service to avoid multiple processes going down? Not sure if we can create a task, which audits the service logs every few minutes. But that will involve some coding and checking of time when the errors happens.

Is there is a straight forward setting like action code we have for process in the business service?

Thanks,

Jimmy Christian.

Product version: Ensemble 2018.1
Discussion (4)0
Log in or sign up to continue

Hi Jimmy,

One approach could be to define a FunctionSet method:

 Class MyRule.FunctionSet Extends Ens.Rule.FunctionSet
{ ClassMethod StopService(serviceName As %String = "") As %Boolean
{
job ##class(Ens.Director).EnableConfigItem(serviceName,0,1)
quit 1
} }

Then in your routing rule that is recieving bad messages from your service you could use the new function:

You might also decide to simply match and suspend bad messages or route to a bad message handler if sequence is not an issue.

Assumes the characters are within the first 10,000 characters of HL7 message.

Hope this helped inspire some ideas.

Cheers,

Alex

Hi Jimmy,

Yes this is using the router context to test if a message has some invalid characters.

As an example I simply used the content "BAD" in the message to demonstrate.

If you want to identify specific characters by numeric code-point an additional FunctionSet method could be employed. For example:

 /// RuleSet function to evaluate whether a given raw input string contains unwanted characters
/// Unwanted characters are supplied as a comma delimited string.
/// For example detect "9,32" would match any ASCII Tab and ASCII space characters
/// The $ASCII function can be used to identify the numeric code point of a character, to be supplied in the detect parameter.
ClassMethod ContainsChars(rawData As %String = "", detect As %String = "") As %Boolean
{
    quit:$Length(rawData)<1 0
    quit:$Length(detect)<1 0
    set found=0
    set len=$Length(detect,",")
    for item=1:1:len {
        set charNum=$Piece(detect,",",item)
        continue:charNum'?1.N
        set char=$Char(charNum)
        if rawData[char {
            $$$TRACE("Found Character "_charNum_" in rawData")
            set found=1
            quit
        }
    }
    quit found
}

Usage example:

Cheers,

Alex