Maps

From Commander4j

A Map is the core configuration unit in Middleware4j. Each map defines a complete message transformation pipeline: where to read data from, how to transform it, and where to send the result. Multiple maps can run simultaneously, each in its own background thread.

Structure

Each map consists of:

  • One input connector — monitors a directory and reads incoming files
  • One or more output connectors — writes the transformed result to one or more destinations
  • Optional XSLT stylesheets on input and/or output for data transformation
  • Optional conditions on each output for content-based routing

How a Map Processes a File

  1. The input connector polls its configured directory at the set interval (default 1000 ms).
  2. When a file matching the file mask arrives, it is read and converted to an internal XML document by the input connector.
  3. If an input XSLT stylesheet is configured, it is applied to transform the XML.
  4. Each output connector is evaluated in turn:
    1. If a condition is configured, the output is only activated when the condition evaluates to true.
    2. If activated, an optional output XSLT stylesheet is applied.
    3. The result is written to the output destination by the output connector.
  5. The original input file is moved to a backup location.
  6. If any step fails, the file is renamed with an .error extension and an email notification is sent (if email is configured).

Configuration

Maps are defined in the main config.xml file. A minimal map looks like this:

<map>
  <id>Map01</id>
  <enabled>true</enabled>
  <description>ASCII File to CSV</description>
  <enableEmailNotifications>true</enableEmailNotifications>
  <connectors>
    <input>
      <id>in1</id>
      <type>ASCII</type>
      <url>
        <path>./interface/input/Map01</path>
        <mask/>
        <pollingInterval>1000</pollingInterval>
      </url>
      <xsl>
        <XSLT>Map01_ASCII_to_CSV.xsl</XSLT>
      </xsl>
      <ascii>
        <pattern>1-10,12-21,23-32</pattern>
      </ascii>
    </input>
    <output>
      <id>out1</id>
      <type>CSV</type>
      <url>
        <path>./interface/output/Map01</path>
      </url>
    </output>
  </connectors>
</map>

Key Settings

Map Level

Setting Description
id Unique identifier for this map (e.g. Map01)
enabled true/false — disabled maps are loaded but do not run
description Human-readable description shown in the GUI
enableEmailNotifications Whether to send error emails for this map

Input Connector

Setting Description
type The connector type: ASCII, CSV, XML, IDOC, Excel, EMAIL, RAW, PDF_PRINT
path The directory to monitor for incoming files
mask File extension filter (leave empty to process all files)
pollingInterval How often to check the directory, in milliseconds
xsl / XSLT Optional XSLT stylesheet to apply after reading

Output Connector

Setting Description
type The connector type: ASCII, CSV, XML, SOCKET, MQTT, EMAIL, Excel, PDF_PRINT, RAW, IDOC
path Output directory (multiple directories separated by semicolons)
xsl / XSLT Optional XSLT stylesheet to apply before writing
use83GUID Use short (8.3) GUID filenames for legacy application compatibility
retainOriginalFilename Keep the original input filename on the output file

Conditional Routing

An output connector can be made conditional using an XPath expression evaluated against the internal XML document. This allows a single map to route different messages to different outputs based on their content.

<condition>
  <param1>/message/messageData/storageBin</param1>
  <param1_Type>xquery</param1_Type>
  <param2>DESPATCH</param2>
  <param2_Type>literal</param2_Type>
  <comparitor>EQUAL</comparitor>
</condition>

Supported comparitors are EQUAL and NOT EQUAL. Either or both parameters can be XPath expressions (xquery) or fixed values (literal).

Multiple Outputs

A single map can have any number of output connectors. All enabled outputs whose conditions are satisfied receive the transformed message. This allows one incoming file to simultaneously update multiple systems in different formats.

Global Settings

Global settings that apply to all maps are defined at the top of config.xml:

Setting Description
logPath Directory for transformation log files
XSLTPath Directory where XSLT stylesheets are stored
logArchiveRetentionDays How many days to keep old log files
retryOpenFileCount Number of times to retry reading a locked file
retryOpenFileDelay Delay in milliseconds between retries
enableEmailNotifications Global email notification toggle
statusReportTime Time of day to send the daily status report email

See also: Connectors, Middleware4j Example Configuration, Overview_Middleware4j