Checking for a value within a stream in the condition of a routing rule
Hello all,
I have a EnsLib.HTTP.GenericMessage inbound from a webhook with a GC stream.
My router is defined as the following:
General Message Routing Rule
The msgClass for said rule is: EnsLib.HTTP.GenericMessage
I have tried a few variants of using a Contains in the condition to check the following: Document.StreamGC.Attributes.
I want to check the Stream for "HITL". If it contains that, we send downstream.
Is there a way to do this within the condition in the rule?
Is the best solution to instead write a function that rewinds the stream and returns a flag?
Thank you!
Comments
In the rule you should be able to have an expression with
Stream.Read(some number of character.. you might consider 3200000)
to get the first X characters of the stream content... of course assuming the thing you are searching for can be found in that string.
The streams we are processing are fairly short. I will give this a shot.
Any suggestion on syntax? I cannot get it to resolve in the rule editor:
Does not play nice.
Thank you
assuming Document.StreamGC is of type %Stream.Object you may
use method FindAt which combines Read() and Contains()
see: method FindAt()
method FindAt(position As %Integer, target As %RawString,
ByRef tmpstr As %RawString = "", caseinsensitive As %Boolean = 0) as %Integer
Find the first occurrence of target in the stream, starting the search at position.
The method returns the position of this match, counting from the beginning of
the stream, and leaves the stream positioned at an indeterminate location.
If it does not find the target string, it returns -1.
If position=-1 then it starts searching from the location found in the
previous search and returns the offset from the last search.
This is useful for searching through the entire file.
If you are doing this, you should pass in tmpstr by reference in every call.
This is used to store the last buffer read, so the next call will start
where the last one left off.
If caseinsensitive=1 then the search will be case insensitive,
rather than the default case-sensitive search.