TNT4J-Streams allows importing external resources into the stream data-source configuration.
External values mapping resources import sample:
<?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">
<resource-ref id="MFT_MAPPINGS" type="ValuesMap" uri="./tnt4j-streams-wmq/samples/mft_fte/mft_mappings.json"/>
<!--<resource-ref id="MFT_MAPPINGS_COMPCODE" type="ValuesMap" uri="./tnt4j-streams-wmq/samples/mft_fte/CompCode.csv" separator=","/>-->
<parser name="ResMappingParser" class="com.jkoolcloud.tnt4j.streams.parsers.ActivityXmlParser">
<field name="EventType" locator="name(//*[1])" locator-type="Label">
<field-map-ref resource="MFT_MAPPINGS.EventType"/>
</field>
<field name="EventName" locator="name(//*[1])" locator-type="Label">
<field-map-ref resource="MFT_MAPPINGS.EventName"/>
</field>
<field name="Direction" locator="name(//*[1])" locator-type="Label" transparent="true"/>
<field name="ResourceName" formattingPattern="{0}={1};Agent={2}">
<!--resolves FILE or QUEUE-->
<field-locator locator="name(//*/*)" locator-type="Label">
<field-map-ref resource="MFT_MAPPINGS.Resource"/>
</field-locator>
<!--resolves file or queue name -->
<field-locator locator="ts:getFileName(/${Direction}/file)" locator-type="Label" required="false"/>
<field-locator locator="ts:getObjectName(/${Direction}/queue)" locator-type="Label" required="false"/>
<!-- agent-->
<field-locator locator="/transaction/${Direction}Agent/@agent" locator-type="Label" required="false"/>
</field>
<field name="CompCode" locator="/transaction/status/@resultCode" locator-type="Label">
<field-map-ref resource="MFT_MAPPINGS.CompCode"/>
</field>
<field name="CompCode2" locator="/transaction/status/@resultCode" locator-type="Label">
<field-map-ref resource="MFT_MAPPINGS.CompCode2"/>
</field>
<.../>
</parser>
<stream name="ResMappingStream">
<.../>
<parser-ref name="ResMappingParser"/>
</stream>
</tnt-data-source>
resource-ref tag) an external resource file ./tnt4j-streams-wmq/samples/mft_fte/mft_mappings.json using a relative file path.
resource-ref ag Attributes
id — Resource identifier and must be unique. Required.
-
type — Defines the type of the imported resource. Required. Supported values:
ValuesMap — The resource file defines source-to-target values mapping.
Parser — The resource file defines an external parser configuration to be injected into the current
tnt-data-sourceconfiguration.
See Referenced resource formats.
uri — Absolute URL or relative file path of the referenced resource. Required.
Note: To access a resource file from the classpath (e.g., when the streams config is packaged into a JAR/WAR or another Java archive), use theclasspath:protocol, for example:classpath:parsers.xml,classpath:res/streams/MsgParsers.xml, orclasspath:StateCodesMap.json.separator — Defines the source/target value delimiter; applicable to CSV and Properties formatted resources. Optional.
Referenced Resource Formats
Supported external resource definition formats:
-
ValuesMaptype resources can be:JSON
{ "EventType": { "destination": "SEND", "source": "RECEIVE", "": "NOOP" }, "EventName": { "destination": "process_destination", "source": "process_source", "": "N/A" }, "Resource": { "file": "FILE", "queue": "QUEUE" }, "CompCode": { "0": "SUCCESS", "40": "WARNING", "": "ERROR" }, "CompCode2": { "0": "SUCCESS", "40": "WARNING", "1": "FAILURE", "": "ERROR" } }CSV
0,SUCCESS 40,WARNING , ERRORProperties
0:SUCCESS 40:WARNING : ERROR
NOTE:
JSONcan contain multiple mapping-definition sets, while CSV and Properties formats support only one mapping set. Parsertype resources can be onlyXMLformat defined content.