This article covers how to configure parsers in meshIQ/TNT4J-Streams — detailing generic parser settings, available parser types (JSON, XML, JMS, etc.), and configuration options for parsing raw activity data.
Generic Parser Parameters
Attributes
manualFieldsOrder— Flag indicating whether configuration-defined fields order shall be preserved in the streaming process. By default, fields are ordered by value-resolution type: RAW activity data values, activity entity fields values, cache entries values. Default value —false.default-data-type— Specifies defaultdatatypeattribute value bound for all fields/locators of this parser. Default value —String. See TNT4J Events field mappings for attributedatatypedetails.default-emptyAsNull— Specifies defaultemptyAsNullattribute value for all fields/locators of this parser. Default value —true.
Sample:
<parser name="TestParser" class="com.my.company.ActivityTestParser" manualFieldsOrder="true" default-data-type="Generic" default-emptyAsNull="false">
<.../>
</parser>Properties
UseActivityDataAsMessageForUnset— Flag indicating whether Raw activity data shall be put into fieldMessageif there is no mapping defined for that field in stream parser configuration or value was not resolved by parser from Raw activity data. NOTE: it is recommended to use it for DEBUGGING purposes only. For a production version of your software, remove this property form stream parser configuration. Default value —false. (Optional)ActivityDelim— Defines activities delimiter symbol/token used by parsers. Value can be one of:EOL— end of line, orEOF— end of file/stream. Default value —EOL. (Optional)-
DelimiterRule— Defines activities delimiter handling rules:-
BEGINNING— delimiter marks beginning of raw activity data. Delimiter itself gets included into raw activity data. Aliases —BEGIN,STARTING,START FROM -
TERMINATING— delimiter marks end of RAW activity data. Delimiter itself gets included into raw activity data. Aliases —TERMINATE,ENDING,END,STOP,TO -
DELIMITING— delimiter is ordinary data chunks separator. Delimiter itself gets omitted from raw activity data. Aliases —SPLIT,DELIM,DELIMIT,SEPARATE,DIVIDE,DIV -
Default value —
TERMINATE. (Optional)
-
-
RequireDefault— Indicates that all parser fields/locators by default are required to resolve to non-null values. Default value —false. (Optional) Thefieldattributerequired="true"(orfalse) may be used to take precedence over theRequireDefaultproperty. Seerequiredattribute definition in TNT4J Events field mappings. AutoArrangeFields— Flag indicating parser fields shall be automatically ordered by parser to ensure references sequence. Whenfalse, fields shall maintain user parser configuration-defined order. NOTE: it is alias for parser configuration attributemanualFieldsOrder. Default value —true. (Optional)Set of user defined parser context properties. To define parser context property add
ctx:prefix to property name. These properties are not used directly by parser itself, but can be used in parser configuration over dynamic locators or variable expressions to enrich parsing context. (Optional)
Sample:
<property name="UseActivityDataAsMessageForUnset" value="true"/> <property name="ActivityDelim" value="EOF"/> <property name="RequireDefault" value="true"/> <property name="AutoArrangeFields" value="false"/>
Common Locators
$DATA$— Allows setting complete activity data as field value and redirect it to stacked parser if such is defined for that field.$METADATA$— Allows accessing activity bound meta-data map. Activity meta-data binding is stream specific: some streams may not provide any meta-data. To get list of stream provided meta-data entries, see particular stream documentation (both JavaDoc and readme).$RAWDATA$— Allows setting complete RAW activity data (one before pre-parsing other preparations) as field value and redirect it to stacked parser if such is defined for that field.Field wildcard locators having
*symbol within field name (e.g.,FieldNameFragment*) are used to capture map of activity entity field values, where map entry key is field name and value is field value.
Activity Name-Value Parser
FieldDelim— Fields separator. Default value —,. (Optional)ValueDelim— Value delimiter. Default value —=. (Optional)Pattern— Pattern used to determine which types of activity data string this parser supports. Whennull, all strings are assumed to match the format supported by this parser. Default value —null. (Optional)StripQuotes— Whether surrounding double quotes should be stripped off. Default value —true. (Optional)EntryPattern— Pattern used to split data into name/value pairs. It should define two RegEx groups namedkeyandvalueused to map data contained values to name/value pair. If any other named groups are defined, then group name is used as the key for the map entry. NOTE: this parameter takes preference onFieldDelimandValueDelimparameters. (Optional)
Sample:
<property name="FieldDelim" value=";"/> <property name="ValueDelim" value="-"/> <property name="Pattern" value="(\S+)"/> <property name="StripQuotes" value="false"/> <property name="EntryPattern"><![CDATA[:(?<key>.*?):(?<value>.[^:]+)]]></property>
Also see Activity map parser regarding higher level parser configuration.
Activity RegEx Parser
Pattern— Contains the regular expression pattern that each data item is assumed to match. (Required)MatchStrategy— Definespatterncreated matcher comparison strategy used against input data string. Value can be one of:MATCH— pattern should match complete input string, orFIND— pattern has to match sub-sequence within input string.
Default value —MATCH. (Optional)
Sample:
-
Index-capturing groups:
<property name="Pattern" value="((\S+) (\S+) (\S+))"/> <property name="MatchStrategy" value="FIND"/> -
Named-capturing groups:
<property name="Pattern"><![CDATA[ (?<CoID>.*)\.(?<ProcessArea>.*)\.(?<InterfaceID>.*)\.(?<HopNr>.*) ]]></property> <property name="MatchStrategy" value="MATCH"/>When
MatchStrategy=FINDis used and regex returns multiple matches, it is possible to access an individual match group by defining theLabeltype locator match index (1can be omitted since it is the default) and a group descriptor (an index or name), following the match index after a period delimiter., e.g.,locator="2.2" locator-type="Label"will return the group indexed by2for match2.locator="3.groupName" locator-type="Label"will return the group namedgroupNamefor match3.
Note that the match index starts from 1, while the group index starts from 0 (group 0 usually means Full match).
-
Expressiontype locators:<field name="EventName"> <field-locator locator-type="Expression"><![CDATA[<table id="(.[^"]*)"]]></field-locator> </field>Resolves individual field value within whole activities data string.
-
Wildcard locators:
<property name="Pattern"><![CDATA[<tbody[^>]*?[^>]*?>((?s).*?)</tbody>]]></property> <.../> <field name="TableBodyData" locator="*.0" locator-type="Label" transparent="true" split="true" datatype="AsInput"> <parser-ref name="TableContentParser" aggregation="Relate"/> </field>This sample crops all
<tbody>content from HTML document. Both match and group (index or name) tokens can be wildcard*, e.g.:*.*— returns all groups for all matches*.1— returns group indexed1for all matches1.*— returns match indexed1all groups2.*Number— returns match indexed2all groups name endingNumber
Also see Generic parser parameters.
Activity Token Parser
FieldDelim— Fields separator. Default value —,. (Optional)Pattern— Pattern used to determine which types of activity-data strings this parser supports. Whennull, all strings are assumed to match the format supported by this parser. Default value —null. (Optional)StripQuotes— Whether surrounding double quotes should be stripped off. Default value —true. (Optional)
Sample:
<property name="FieldDelim" value=";"/> <property name="Pattern" value="(\S+)"/> <property name="StripQuotes" value="false"/>
Also see Generic parser parameters.
Activity XML Parser
This parser uses XPath expressions as field locators. You may also use TNT4J-Streams predefined custom XPath functions.
Namespace— Additional XML namespace mappings. Default value —null. (Optional)NamespaceAware— Indicates that the parser has to provide support for XML namespaces. Default value —true. (Optional)IsolateNodeXML— Indicates that the parser shall isolate the provided DOM Node XML and use it as a standalone document, omitting references to the parent node/document. Default value —true. (Optional)FallbackToParent— Indicates that the parser shall try to resolve a value using the parent document scope if it was unable to resolve the value using the relative context (when the XPath expression has a “wider” scope than the “current” node provides). Default value —true. (Optional)
Sample:
<property name="Namespace" value="xsi=http://www.w3.org/2001/XMLSchema-instance"/> <property name="Namespace" value="tnt4j=https://xray.meshiq.com/xray/xsds"/> <property name="NamespaceAware" value="false"/>
XML Parser Provided Metadata
XML parser provides the following activity metadata entries (accessible using the $METADATA$ locator):
MD_XML_PARENT_NODE_NAME— Parent node name when the parser hasIsolateNodeXMLset totrue.
Also see Generic parser parameters.
Message Activity XML Parser
Also see Activity XML parser and Generic parser parameters.
MQ message Signature Calculation
For MQ messages it is possible to calculate a message signature from message fields. To initiate signature calculation as a field value, the field tag value-type attribute value has to be set to signature.
Sample of field definition for signature calculation:
<field name="TrackingId" separator="#!#" value-type="signature">
<field-locator locator="/messaging_operation/MsgType" locator-type="Label" datatype="Number"/>
<field-locator locator="/messaging_operation/MsgFormat" locator-type="Label"/>
<field-locator locator="/messaging_operation/MsgId" locator-type="Label" datatype="Binary" format="hexBinary"/>
<field-locator locator="/messaging_operation/MsgUser" locator-type="Label">
<field-transform name="UserIdLowerCase" lang="groovy">
StringUtils.lowerCase($fieldValue)
</field-transform>
</field-locator>
<field-locator locator="/messaging_operation/MsgPutApplType" locator-type="Label"/>
<field-locator locator="/messaging_operation/MsgPutApplName" locator-type="Label"/>
<field-locator locator="/messaging_operation/MsgPutDate" locator-type="Label"/>
<field-locator locator="/messaging_operation/MsgPutTime" locator-type="Label"/>
<field-locator locator="/messaging_operation/Correlator" locator-type="Label"/>
</field>Apache Access Log Parser
LogPattern— Access-log pattern. (Optional, if RegExPatternproperty is defined)ConfRegexMapping— Custom log-pattern token (must be wildcard or RegEx-compliant string) and RegEx mapping. (Optional, applicable only ifLogPatternis used)
Sample: Using a log pattern with custom mappings:
<property name="LogPattern" value="%h %l %u %t "%r" %s %b %D"/>
<property name="ConfRegexMapping" value="%h=(\S+)"/>
<property name="ConfRegexMapping" value="%*s=(\d{3})"/>
<property name="ConfRegexMapping" value="%*r=(((\S+) (.*?)( (\S+)|()))|(-))"/>
<property name="ConfRegexMapping" value="%*i=(.*?)"/>Or defining a complete RegEx pattern to match log lines:
<property name="Pattern"
value="^(\S+) (\S+) (\S+) \[([\w:/]+\s[+\-]\d{4})\] "(((\S+) (.*?)( (\S+)|()))|(-))" (\d{3}) (\d+|-)( (\S+)|$)"/>
<property name="ConfRegexMapping"><![CDATA[%*r=(?<request>((?<method>\S+) (?<uri>.*?)( (?<version>\S+))?)|(-))]]></property>
| Label (RegEx group name) | Format String | Description |
|---|---|---|
| address | %a | Client IP address of the request (see the mod_remoteip module). |
| local_address | %A | Local IP-address. |
| size | %B | Size of response in bytes, excluding HTTP headers. |
| size_clf | %b | Size of response in bytes, excluding HTTP headers. In CLF format, e.g., a '-' rather than a 0 when no bytes are sent. |
| cookie | %{VARNAME}C | The contents of cookie VARNAME in the request sent to the server. Only version 0 cookies are fully supported. |
| req_time | %D | The time taken to serve the request, in microseconds. |
| env_variable | %{VARNAME}e | The contents of the environment variable VARNAME. |
| filename | %f | Filename. |
| hostname | %h | Remote hostname. Will log the IP address if HostnameLookups is set to Off, which is the default. If it logs the hostname for only a few hosts, you probably have access control directives mentioning them by name. See the Require host documentation. |
| protocol | %H | The request protocol. |
| variable | %{VARNAME}i | The contents of VARNAME: header line(s) in the request sent to the server. Changes made by other modules (e.g., mod_headers) affect this. If you're interested in what the request header was prior to when most modules would have modified it, use mod_setenvif to copy the header into an internal environment variable and log that value with the %{VARNAME}e described above. |
| keep_alive | %k | Number of keepalive requests handled on this connection. Interesting if KeepAlive is being used, so that, for example, a 1 means the first keepalive request after the initial one, 2 the second, etc.; otherwise this is always 0 (indicating the initial request). |
| logname | %l | Remote logname (from identd, if supplied). This will return a dash unless mod_ident is present and IdentityCheck is set On. |
| method | %m | The request method. |
| note | %{VARNAME}n | The contents of note VARNAME from another module. |
| header_var | %{VARNAME}o | The contents of VARNAME: header line(s) in the reply. |
| port | %{format}p | The canonical port of the server serving the request, or the server's actual port, or the client's actual port. Valid formats are canonical, local, or remote. |
| process | %{format}P | The process ID or thread ID of the child that serviced the request. Valid formats are pid, tid, and hextid. hextid requires APR 1.2.0 or higher |
| query | %q | The query string (prepended with a ? if a query string exists, otherwise an empty string). |
| line | %r | First line of request. |
| resp_handler | %R | The handler generating the response (if any). |
| status | %s | Status. For requests that have been internally redirected, this is the status of the original request. Use %>s for the final status. |
| time | %{format}t | The time, in the form given by format, which should be in an extended strftime(3) format (potentially localized). If the format starts with begin: (default) the time is taken at the beginning of the request processing. If it starts with end: it is the time when the log entry gets written, close to the end of the request processing.In addition to the formats supported by strftime(3), the following format tokens are supported: |
| req_time_ext | %{UNIT}T | The time taken to serve the request, in a time unit given by UNIT. Valid units are ms for milliseconds, us for microseconds, and s for seconds. Using s gives the same result as %T without any format; using us gives the same result as %D. Combining %T with a unit is available in 2.4.13 and later. |
| user | %u | Remote user if the request was authenticated. May be bogus if return status (%s) is 401 (unauthorized). |
| uri | %U | The URL path requested, not including any query string. |
| server_name | %v | The canonical ServerName of the server serving the request. |
| server_name_ext | %V | The server name accordingto the UseCanonicalName setting. |
| con_status | %X | Connection status when response is completed: |
| received | %I | Bytes received, including request and headers. Cannot be zero. You need to enable mod_logio to use this. |
| sent | %O | Bytes sent, including headers. May be zero in rare cases such as when a request is aborted before a response is sent. You need to enable mod_logio to use this. |
Also see Generic parser parameters.
Activity Map Parser
-
LocPathDelim— locator path delimiter in a map. An empty value means the locator value should not be delimited into path elements. Default value —.. (Optional)
Sample:
<property name="LocPathDelim" value="/"/>
Also see Generic parser parameters.
Wildcard Locators
Using locator path token value * (e.g., locator="*") you can make the parser take all map entries from that level and output them as activity entity fields/properties by using map entry data as follows:
Map entry key — field/property name
Map entry value — field/property value
Locator path token * can be omitted if the last path token resolves to java.util.Map type value. However, to get the complete map for the root path level you must define it locator="*" anyway, since the locator value can't be empty.
Using locator path token value # (e.g., locator="#") you can make the parser get all yet parser un-touched map entries from that level and output them as activity entity fields/properties by using map entry data as follows:
Map entry key — field/property name
Map entry value — field/property value
This allows the user to map part of the entries manually and the remainder automatically. Consider a map having the following entries:
entry1: key=key1, value=value1 entry2: key=key2, value=value2 entry3: key=key3, value=value3
Then, using parser configuration:
<field name="Message" locator="key2" locator-type="Label"/> <field name="AllRestMapEntries" locator="#" locator-type="Label"/>
Message=value2 key1=value1 key3=value3
# locator without any manual map entry mapping is equivalent to * locator.Functional Locators
.size()(or.length()) — returns size of prefix locator expression resolved value being of type:array,collectionormap. Example:events.size()will return size ofeventslist..keys()— returns key set for prefix locator expression resolved map. Example:timeseries.keys()will return keys oftimeseriesmap..values()— returns values collection for prefix locator expression resolved map. Example:timeseries.values()will return values collection oftimeseriesmap..entries()— returns entry set for prefix locator expression resolved map. Example:timeseries.entries()will return entry set oftimeseriesmap.
Activity JSON Parser
We have two classes implementing JSON parser. Difference is type of expressions used for parsing:
- com.jkoolcloud.tnt4j.streams.parsers.ActivityJsonParser - uses JSONPath expressions for parsing
Sample file:<tnt4j-streams>/tnt4j-streams-core/src/main/java/com/jkoolcloud/tnt4j/streams/parsers/ActivityJsonParser.java - com.jkoolcloud.tnt4j.streams.parsers.ActivityJsonJMESPathParser - uses JMESPath expressions for parsing
Sample file:<tnt4j-streams>/tnt4j-streams-core/src/main/java/com/jkoolcloud/tnt4j/streams/parsers/ActivityJsonJMESPathParser.java
Configuration properties:
ReadLines— indicates that complete JSON data package is single line. Default value —true. (Optional, deprecated — useActivityDelimof Generic parser instead)List of
DeserializationFeature.[FEATURE_NAME]— defines set of Jackson Object Mapper's deserialization configuration features. SeeDeserializationFeature. (Optional)List of
MapperFeature.[FEATURE_NAME]— defines set of Jackson Object Mapper's mapping configuration features. SeeMapperFeature. (Optional)List of
JsonParser.[FEATURE_NAME]— defines set of Jackson Object Mapper's parser configuration features. SeeJsonParser.Feature. (Optional)List of
Option.[OPTION_NAME]— defines set of JsonPath configuration options. SeeOption. (Optional)
Sample:
<property name="ReadLines" value="false"/> <!-- Jackson Object Mapper's Deserialization features --> <property name="DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS" value="false"/> <property name="DeserializationFeature.USE_BIG_INTEGER_FOR_INTS" value="false"/> <property name="DeserializationFeature.USE_LONG_FOR_INTS" value="false"/> <property name="DeserializationFeature.USE_JAVA_ARRAY_FOR_JSON_ARRAY" value="false"/> <property name="DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES" value="true"/> <.../> <!-- Jackson Object Mapper's mapping features --> <property name="MapperFeature.USE_ANNOTATIONS" value="true"/> <property name="MapperFeature.USE_GETTERS_AS_SETTERS" value="true"/> <property name="MapperFeature.PROPAGATE_TRANSIENT_MARKER" value="false"/> <property name="MapperFeature.AUTO_DETECT_CREATORS" value="true"/> <property name="MapperFeature.AUTO_DETECT_FIELDS" value="true"/> <.../> <!-- Jackson Object Mapper's parser features --> <property name="JsonParser.AUTO_CLOSE_SOURCE" value="true"/> <property name="JsonParser.ALLOW_COMMENTS" value="false"/> <property name="JsonParser.ALLOW_YAML_COMMENTS" value="false"/> <property name="JsonParser.ALLOW_UNQUOTED_FIELD_NAMES" value="false"/> <.../> <!-- JsonPath configuration options --> <property name="Option.DEFAULT_PATH_LEAF_TO_NULL"/> <property name="Option.ALWAYS_RETURN_LIST"/> <property name="Option.AS_PATH_LIST"/> <.../>
Also see Generic parser parameters.
Activity JMS Message Parser
-
ConvertToString— flag indicating whether to convert message payloadbyte[]data to string. Applicable toBytesMessageandStreamMessage. Default value —false. (Optional)
Sample:
<property name="ConvertToString" value="true"/>
Additional JMS message fields and mappings are supported by these locators for this parser:
MsgMetadata — JMS message metadata map containing these fields:
Correlator— message correlation identifierCorrelatorBytes— message correlation identifier bytes valueDeliveryMode— message delivery mode numberDeliveryTime— message delivery time valueDestination— destination name this message was received fromExpiration— message's expiration timeMessageId— message identifier stringPriority— message priority level numberRedelivered— indication flag of whether this message is being redeliveredReplyTo— destination name to which a reply to this message should be sentTimestamp— timestamp in millisecondsType— message type name supplied by the client when the message was sent
CustomMsgProps — map of custom JMS message properties added into JMS message while message was produced, so properties naming is arbitrary upon message producer application.
Since JMS message parser is extension of Activity map parser, it supports map entry Wildcard locators:
-
*— maps all JMS message resolved map entries to activity entity data, e.g.:<field name="AllMsgCustomProps" locator="MsgMetadata.CustomMsgProps.*" locator-type="Label"/>
This will add allMsgMetadata.CustomMsgPropsmap entries as JKool activity entity fields/properties without any additional manual mapping, taking field/property name from map entry name and value from map entry value. The same way you can map allMsgMetadatamap entries into activity entity fields/properties (note omitted locator.*token, see Wildcard locators for details):<field name="MsgMetadata" locator="MsgMetadata" locator-type="Label"/>
-
#— maps set of unmapped JMS message resolved map entries to activity entity data, e.g.:<field name="Correlator" locator="MsgMetadata.Correlator" locator-type="Label"/> <field name="Destination" locator="MsgMetadata.Destination" locator-type="Label"/> <field name="MessageId" locator="MsgMetadata.MessageId" locator-type="Label"/> <field name="Priority" locator="MsgMetadata.Priority" locator-type="Label"/> <!-- automatically puts all unmapped message metadata map entries as custom activity properties --> <field name="AllRestMsgMetadataProps" locator="MsgMetadata.#" locator-type="Label"/>This will add all manually unmappedMsgMetadatamap entries as JKool activity entity fields/properties, taking field/property name from map entry name and value from map entry value.
Using # locator without any manual map entry mapping is equivalent to * locator.
Also see Activity map parser and Generic parser parameters.
Kafka Consumer Record Parser
See Generic parser parameters for general parser configuration. This parser does not have any additional configuration properties.
List of predefined locators for this parser:
topic— topic this record is received frompartition— partition from which this record is receivedoffset— position of this record in the corresponding Kafka partitiontimestamp— timestamp of this recordtimestampType— timestamp type of this recordserializedKeySize— size of the serialized, uncompressed key in bytesserializedValueSize— size of the serialized, uncompressed value in byteskey— record keyvalue— record dataheaders— record headers iterableleaderEpoch— record leader epoch
Kafka Producer Record Parser
See Generic parser parameters for general parser configuration. This parser does not have any additional configuration properties.
List of predefined locators for this parser:
topic— topic name record is being sent topartition— partition identifier to which the record will be senttimestamp— record timestamp valuekey— record keyvalue— record dataheaders— record headers iterable
Activity PCF Parser
-
TranslateNumValues— indicates that parser should translate resolved numeric values to corresponding MQ constant names if possible and field/locator data type isString(meaning translated value can be assigned to field). If value of particular field should be left as number (e.g.,ReasonCode), use field/locator attributedatatype="Number". Default value —true. (Optional)
Sample:
<property name="TranslateNumValues" value="false"/>
byte[]) value and locator data type is set to String having attribute charset undefined, conversion from binary to string value is performed using PCF parameter defined charset (CCSID). If PCF parameter provided charset parameter does not provide correct charset identifier (e.g., value is 0, but streams are run on different platform comparing to message source platform), then to convert binary value to String use charset attribute, e.g.:<field-locator locator="MQGACF_ACTIVITY_TRACE.MQBACF_MSG_ID" locator-type="Label" datatype="String" charset="IBM500"/>
<field name="Message" locator="MQGACF_ACTIVITY_TRACE.MQBACF_MSG_ID" locator-type="Label" datatype="Binary">
<field-transform name="MsgIdToString" lang="groovy"><![CDATA[
Utils.getString($fieldValue, "IBM500")
]]>
</field-transform>
</field>
<field name="MQTrace_CodedCharsetId" locator="MQGACF_ACTIVITY_TRACE.MQIA_CODED_CHAR_SET_ID" locator-type="Label" datatype="Number"/>
<field name="Message" locator="MQGACF_ACTIVITY_TRACE.MQBACF_MESSAGE_DATA" locator-type="Label" datatype="Binary">
<field-transform name="MsgPayloadToString" lang="groovy"><![CDATA[
WmqUtils.getString($fieldValue, ${MQTrace_CodedCharsetId})
]]>
</field-transform>
</field>
DLH and XQH structures data from binary data, leaving only message payload data as result:<field name="MQTrace_CodedCharsetId" locator="MQGACF_ACTIVITY_TRACE.MQIA_CODED_CHAR_SET_ID" locator-type="Label" datatype="Number"/>
<field name="Message" locator="MQGACF_ACTIVITY_TRACE.MQBACF_MESSAGE_DATA" locator-type="Label" datatype="Binary">
<field-transform name="MsgPayloadToString" lang="groovy"><![CDATA[
WmqUtils.getString($fieldValue, ${MQTrace_CodedCharsetId}, WmqUtils.MQ_BIN_STR_STRIP_DLH_XQH)
]]>
</field-transform>
</field>
In this case if DLH/XQH headers data has CCSID value defined (> 0) within, then that CCSID value is used to convert payload from binary to String. If headers data does not define CCSID value, second parameter value is used. Third function parameter is DLH/XQH headers handling options mask and be one of:
WmqUtils.MQ_BIN_STR_PRESERVE_DLH_XQH— preservesDLH/XQHheaders dataWmqUtils.MQ_BIN_STR_STRIP_DLH_XQH— strips offDLH/XQHheaders data
WmqUtils.getString differs from Utils.getString over second parameter:
WmqUtils.getString— second parameter is CCSID (numeric value) from WMQ defined set, ornullto use WMQ system default encoding (in most cases it will beUTF-8).Utils.getString— second parameter is a Java supported charset/encoding name (in string format) for field Raw binary data; used to convert between Unicode and a number of other character encodings. If no second parameter is specified, the default value is the running streams JVM default charset (in most casesUTF8).
A CCSID used in an expression should be a decimal number without a leading zero 0, which in Java means an octal representation of the number; most likely not what you wanted. Example: Test if a received MQ message is EBCDIC code page 37. If 037 (CCSID name alias) value is used, the comparison would be against decimal value 31, not 37, and would never match. Sample transformation:
<field-transform name="MsgEbcdicOrNot" lang="groovy"><![CDATA[
${MQTrace_CodedCharsetId} == 37 ? $fieldValue : "MSG NOT EBCDIC"
]]>
</field-transform>Also see Generic parser parameters.
MQ Message Signature Calculation
For MQ messages it is possible to calculate message signature from message fields. To initiate signature calculation as a field value, field tag value-type attribute value has to be set to signature.
Sample of field definition for signature calculation:
<field name="Correlator" value-type="signature">
<field-locator locator="MQGACF_ACTIVITY_TRACE.MQIACF_MSG_TYPE" locator-type="Label" datatype="Number"/>
<field-locator locator="MQGACF_ACTIVITY_TRACE.MQCACH_FORMAT_NAME" locator-type="Label"/>
<field-locator locator="MQGACF_ACTIVITY_TRACE.MQBACF_MSG_ID" locator-type="Label" datatype="String" format="bytes"/>
<field-locator locator="MQCACF_USER_IDENTIFIER" locator-type="Label">
<field-transform name="UserIdLowerCase" lang="groovy">
StringUtils.lowerCase($fieldValue)
</field-transform>
</field-locator>
<field-locator locator="MQIA_APPL_TYPE" locator-type="Label"/>
<field-locator locator="MQCACF_APPL_NAME" locator-type="Label"/>
<field-locator locator="MQGACF_ACTIVITY_TRACE.MQCACF_PUT_DATE" locator-type="Label"/>
<field-locator locator="MQGACF_ACTIVITY_TRACE.MQCACF_PUT_TIME" locator-type="Label"/>
<field-locator locator="MQGACF_ACTIVITY_TRACE.MQBACF_CORREL_ID" locator-type="Label" datatype="Binary" required="false"/>
</field>PCF Parameter Locators
PCF message can have grouped parameters — all messages will have header MQCFH and may have MQCFGR type parameters.
To access PCF message header fields use
MQCFHexpression with header field name delimited using.(e.g.,MQCFH.CompCode).To access PCF message parameters use MQ constant name/value (e.g.,
MQCACF_APPL_NAMEor3024).To access inner
MQCFGR(or inner-inner and so on) parameters use group parameter MQ constant name/value with grouped parameter MQ constant name/value delimited using.(e.g.,MQGACF_ACTIVITY_TRACE.MQIACF_COMP_CODE).In case PCF parameter refers
MQIstructure, inner (or inner-inner and so on) structure fields can be accessed by adding.delimited MQI structure fields names to locator path after root MQI structure parameter identifier (e.g.,MQGACF_ACTIVITY_TRACE.MQBACF_MQMD_STRUCT.MsgIdorMQGACF_ACTIVITY_TRACE.MQBACF_MQCNO_STRUCT.clientConn.userIdentifier).Additionally
PCFMessagemay containMQMDdata copied from transportMQMessage. To accessMQMDvalues useMQMDexpression with field name (or relative PCF parameter constant) delimited using.(e.g.,MQMD.PutApplName,MQMD.MQCACF_APPL_NAMEorMQMD.3024).
IBM MQ Error Log Entries Parser
This parser has no additional configuration properties.
Also see Activity map parser regarding higher level parser configuration.
This parser resolved data map may contain such entries:
Date— resolved log entry date stringTime— resolved log entry time stringProcess— resolved log entry process identifierUser— resolved log entry user nameProgram— resolved log entry program (application) nameHost— resolved log entry host name IBM MQ is running onInstallation— resolved log entry IBM MQ installation nameVRMF— resolved log entry running IBM MQ version descriptorQMgr— resolved log entry Queue manager error occurred onErrCode— resolved log entry IBM MQ error code stringErrText— resolved log entry IBM MQ error message textExplanation— resolved log entry IBM MQ error explanation message textAction— resolved log entry IBM MQ error fix action message textWhere— resolved log entry error descriptor location string containing source code file name and line number
IBM MQ versions starting 9.1 adds these additional entries:
Severity— resolved log entry severity:'I'— INFO'W'— WARNING'E'— ERROR'S'— CRITICAL'T'— HALTTimeUTC— resolved log entry UTC timeCommentInsert(X)— resolved log entry text attribute values, have been insert into log entry message, where(X)is attribute indexArithInsert(X)— resolved log entry numeric attribute values, have been insert into log entry message, where(X)is attribute index
Activity Java Object (POJO) Parser
-
SupportedClass— defines class name of parser supported objects. Parser can have multiple definitions of this property. It is useful when just some specific set of objects has to be handled by this parser instead of all passed objects. (Optional)
Sample:
<property name="SupportedClass" value="org.apache.kafka.common.TopicPartition"/> <property name="SupportedClass" value="com.jkoolcloud.tnt4j.streams.custom.interceptors.kafka.reporters.trace.KafkaTraceEventData"/>
Also see Generic parser parameters regarding higher level parser configuration.
Activity String Parser
This parser has no additional configuration properties.
Also see Generic parser parameters regarding higher level parser configuration.
IBM MQ RFH2/JMS Binary Data Parser
This parser has no additional configuration properties.
Also see Activity map parser regarding higher level parser configuration.
This parser resolved data map may contain such entries:
rfh2Folders— RFH2 folders data XML string. Root element for this XML is<rfh2Folders>. Further XPath based parsing can be processed by Activity XML parserjmsMsgPayload— JMS message payload data: de-serialized object or bytes if serialisation can't be done.
Activity MS Excel Parser
-
UseFormattedCellValue— indicator flag stating to use formatted cell value (alwaysString) as field/locator RAW data. When this flag is set totrue— original cell value provided by Apache POI API is used e.g., making all numeric cells values as decimals (double) what is not very comfortable when entered cell value isinteger. Default value —false. (Optional)
Sample:
<property name="UseFormattedCellValue" value="true"/>
Also see Generic parser parameters regarding higher level parser configuration.
Activity JDBC ResultSet Parser
-
SQLJavaMapping— defines mapping from SQL type name (asString) to class (asClass.forName(String)) names in the Java programming language, e.g.NUMBER=java.lang.String. Parser can have multiple definitions og this property. It is useful when default JDBC driver mapping produces inaccurate result. IMPORTANT: if JDBC driver does not supportjava.sql.ResultSet.getObject(int, Map)orjava.sql.ResultSet.getObject(String, Map)implementation, leave SQL-Java types map empty! (Optional)
Also see Generic parser parameters regarding higher level parser configuration.
Pre-Parsers
The TNT4J-Streams architecture has a pre-parser entity that defines a data transformation algorithm to convert Raw activity data to a format supported by the stream’s parser. Pre-parsers must implement the ActivityDataPreParser interface.
It is possible to define multiple pre-parsers for the same parser instance. In that case, pre-parsers are applied sequentially (the sequence is defined by the order of the reference tags within the parser tag), where the input of the applied pre-parser is the output of the previous pre-parser.
XML From Binary Data Pre-Parser
What it does
Retrieves XML data from a mixture of binary and string data (like RFH2).
Makes an incomplete XML string fragment into a complete (DOM-valid) XML string.
Sample stream configuration using BinaryToXmlPreParser pre-parser
<?xml version="1.0" encoding="utf-8"?>
<tnt-data-source
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://meshiq-xsd.s3.amazonaws.com/streams/tnt-data-source.xsd">
<java-object name="RFH2ToXMLPreParser" class="com.jkoolcloud.tnt4j.streams.preparsers.BinaryToXmlPreParser">
<!-- IF Raw ACTIVITY DATA STRING IS ENCODED - USE "format" PARAMETER. SEE BELOW -->
<!--<param name="format" value="base64Binary" type="java.lang.String"/>-->
<!-- IF RAW ACTIVITY DATA IS ENCODED USING CHARSET - USE "charsetName" PARAMETER. SEE BELOW -->
<!--<param name="charsetName" value="UTF-16" type="java.lang.String"/>-->
</java-object>
<parser name="RFH2XMLParser" class="com.jkoolcloud.tnt4j.streams.parsers.ActivityXmlParser">
<reference name="RFH2ToXMLPreParser"/>
<field name="EventType" value="Event"/>
<field name="ApplName" value="Sample"/>
<field name="ADPCount" locator="/root/usr/ADPSegCont" locator-type="Label"/>
</parser>
<stream name="FileStream" class="com.jkoolcloud.tnt4j.streams.inputs.BytesInputStream">
<property name="FileName" value="./tnt4j-streams-core/samples/XML-from-bin-data/RFH2.dump"/>
<property name="RestoreState" value="false"/>
<parser-ref name="RFH2XMLParser"/>
</stream>
</tnt-data-source>The sample configuration defines FileStream reading binary data from RFH2.dump. The stream refers to the activity XML parser RFH2XMLParser.
The RFH2XMLParser parser has a reference to RFH2ToXMLPreParser. This pre-parser builds valid XML from provided binary data having fragmented XML data like the RFH2 structure from IBM MQ.
If Raw activity data is not byte[] but appears to be encoded (e.g., BASE64), use the pre-parser property format to define the Raw activity data format. It may be one of the ActivityFieldFormatType enumeration values:
base64Binary— BASE64 encoded binary datahexBinary— binary data represented as bytes HEX codes sequencestring— binary data represented as plain stringbytes— binary data asbyte[](default)
Transformation Pre-Parser
What it does
Applies a user-defined transformation bean or script code to convert/alter parser input Raw activity data.
Used configuration properties
id— transformation identifier. (Optional)lang— transformation script language. (Optional)script— code of the transformation script (can’t be mixed withbeanRef). (Required)beanRef— transformation bean reference (can’t be mixed withscript). (Required)useParserInput— flag indicating whether to use the parser-provided input read function. Default value —true. (Optional)
Sample stream configuration using TransformationPreParser pre-parser:
<?xml version="1.0" encoding="utf-8"?>
<tnt-data-source xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://meshiq-xsd.s3.amazonaws.com/streams/tnt-data-source-wmq_pcf.xsd">
<java-object name="UnescapePreParser" class="com.jkoolcloud.tnt4j.streams.preparsers.TransformationPreParser">
<property name="id" value="unescape"/>
<property name="lang" value="groovy"/>
<property name="useParserInput" value="false"/>
<property name="script"><![CDATA[
StringEscapeUtils.unescapeJava($fieldValue)
]]></property>
</java-object>
<parser name="XML_Data_Parser" class="com.jkoolcloud.tnt4j.streams.parsers.ActivityXmlParser">
<reference name="UnescapePreParser"/>
<.../>
</parser>
</tnt-data-source>
XML_Data_Parser has a reference to UnescapePreParser to un-escape (remove excessive \") stream-provided Raw activity string data.Also see Field value transformations regarding the use of streamed data transformations.
TransformationPreParser does not support the transformation property phase, since it is always applied on parser input Raw activity data before data gets parsed by the enclosing parser.