Overview Middleware4j: Difference between revisions
Updated by push_wiki.py |
Updated by push_wiki.py |
||
| Line 1: | Line 1: | ||
Middleware4j is | '''Middleware4j''' converts files from one format to another and delivers the result where it is needed. It was written as a companion to [[Commander4j]], but it has no dependency on it and can be used on its own for any file based integration. | ||
A typical use is linking Commander4j to an ERP system: a material master arrives from SAP as an IDOC and is turned into the XML that Commander4j imports, or a Commander4j production declaration is turned into the CSV file that Sage expects. | |||
== The idea in one picture == | |||
Everything Middleware4j does is described by a '''[[Maps|map]]'''. A map has three parts, and data always flows through them in the same order. | |||
<pre> | |||
file arrives result is | |||
in a folder delivered | |||
| ^ | |||
v | | |||
+-----------------+ +-----------------+ +--------------------------+ | |||
| INPUT CONNECTOR | | MAP | | OUTPUT CONNECTOR(S) | | |||
| | XML | (XSLT) | XML | | | |||
| native format | -----> | rearranges the | -----> | XML to the target format | | |||
| to XML | | XML | | one or many per map | | |||
+-----------------+ +-----------------+ +--------------------------+ | |||
CSV, fixed width, your stylesheet CSV, fixed width, XML, | |||
XML, IDOC, Excel Excel, socket, MQTT | |||
</pre> | |||
# The '''input connector''' watches a folder. When a file arrives it reads it and converts it into XML. A CSV file, for example, becomes a list of rows and columns written as XML. | |||
# The '''map''' is an XSLT stylesheet. It receives the XML from the input connector and rearranges it into the XML that the output connector needs. | |||
# The '''output connector''' takes that XML and writes it in the target format: a CSV file, a fixed width text file, an XML file, a spreadsheet, or data sent to a network device. | |||
Two rules are worth remembering: | |||
== | * A map has exactly '''one input''' connector, so one input format. | ||
* A map can have '''several output''' connectors. One incoming file can produce a CSV file for one system and an XML file for another at the same time. | |||
The stylesheet never writes CSV or text itself. It always writes XML, in the layout the chosen output connector expects, and the connector does the final conversion. Those layouts are listed on the [[Connectors]] page, and [[Creating a Map]] walks through building a map from start to finish. | |||
== What you edit == | |||
There is no configuration screen. A map is made from two kinds of text file: | |||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
! | ! File !! Where !! What it holds | ||
|- | |- | ||
| [[ | | <code>config.xml</code> || <code>xml/config</code> || The list of maps: which folder to watch, which connector types to use, where to write the results. See [[Maps]]. | ||
|- | |- | ||
| [[ | | A stylesheet (<code>.xsl</code>) || <code>xslt</code> || The transformation for one map. See [[Creating a Map]] and [[XSLT Extension Functions]]. | ||
|} | |||
Middleware4j reads <code>config.xml</code> when it starts, so restart it after changing a map. | |||
== Supported formats == | |||
The '''Type''' column is the value used in <code>config.xml</code>. | |||
{| class="wikitable" | |||
|- | |- | ||
! Format !! Type !! Input !! Output | |||
|- | |- | ||
| | | [[ASCII]] fixed column text files || <code>ASCII</code> || Yes || Yes | ||
|- | |- | ||
| | | [[CSV]] delimited text files || <code>CSV</code> || Yes || Yes | ||
|- | |- | ||
| [[ | | [[XML]] documents || <code>XML</code> || Yes || Yes | ||
|- | |||
| [[IDOC]] SAP flat file IDOCs || <code>IDOC</code> || Yes || No | |||
|- | |||
| [[EXCEL|Excel]] spreadsheets || <code>XLS</code> for input, <code>EXCEL</code> for output || Yes || Yes | |||
|- | |||
| [[SOCKET]] send to a TCP/IP device || <code>SOCKET</code> || No || Yes | |||
|- | |||
| [[MQTT]] publish to an MQTT broker || <code>MQTT</code> || No || Yes | |||
|} | |||
Three more connector types move a file without converting it. Each is used as a matched pair, with the same type on the input and the output, and no stylesheet is involved. | |||
{| class="wikitable" | |||
|- | |- | ||
! Purpose !! Type | |||
|- | |- | ||
| [[ | | [[RAW]] copy or move a file to one or more folders || <code>RAW</code> | ||
|- | |- | ||
| [[ | | [[EMAIL]] send a file as an email attachment || <code>EMAIL</code> | ||
|- | |- | ||
| | | [[PDF PRINT|PDF_PRINT]] print a PDF file on a named printer || <code>PDF_PRINT</code> | ||
|} | |} | ||
== | == The transformation engine == | ||
Stylesheets are run by '''Saxon-HE 12''', which supports XSLT 2.0 and 3.0. Middleware4j adds its own [[XSLT Extension Functions|extension functions]] for padding, trimming and date conversion, and stylesheets can look up values from reference data files held next to them. | |||
The installation includes two sets of samples: | |||
* <code>samples/basic</code> holds fourteen small maps, Map01 to Map14, covering each connector type. These are the maps in the <code>config.xml</code> that is installed, so they are ready to try as soon as the program is started. | |||
* <code>samples/advanced</code> holds over fifty maps and their stylesheets, taken from real integrations between Commander4j and SAP, Sage, Tropos and B2MML (S95) systems. They are the best starting point for a new map of your own. | |||
Middleware4j | == Running Middleware4j == | ||
{| class="wikitable" | {| class="wikitable" | ||
| Line 58: | Line 99: | ||
! Mode !! Description | ! Mode !! Description | ||
|- | |- | ||
| '''Service''' || Runs | | '''Service''' || Runs in the background with no user interface. This is the normal way to run in production. See [[Installation Middleware4j]]. | ||
|- | |- | ||
| ''' | | '''Desktop''' || Opens a window listing the maps, their folders and a running count of files in and out. Useful while building and testing a map. See [[Middleware Example Screen]]. | ||
|} | |} | ||
Every map runs independently, each checking its own input folder at its own interval. | |||
== | == Keeping an eye on it == | ||
* Every file received, and every stage of its conversion, is copied to <code>interface/log</code>. See [[Creating a Map#Seeing what happened|Seeing what happened]]. | |||
* Problems are reported by email to the '''Error''' distribution list, and a daily count of files processed is sent to the '''Monitor''' list. See [[EMAIL]]. | |||
See also: [[Maps]], [[Connectors]], [[Middleware4j Example Configuration]], [[Installation Middleware4j]] | See also: [[Maps]], [[Connectors]], [[Creating a Map]], [[Middleware4j Example Configuration]], [[Installation Middleware4j]] | ||
[[Category:Middleware4j]] | [[Category:Middleware4j]] | ||
Latest revision as of 21:47, 9 November 2026
Middleware4j converts files from one format to another and delivers the result where it is needed. It was written as a companion to Commander4j, but it has no dependency on it and can be used on its own for any file based integration.
A typical use is linking Commander4j to an ERP system: a material master arrives from SAP as an IDOC and is turned into the XML that Commander4j imports, or a Commander4j production declaration is turned into the CSV file that Sage expects.
The idea in one picture
Everything Middleware4j does is described by a map. A map has three parts, and data always flows through them in the same order.
file arrives result is
in a folder delivered
| ^
v |
+-----------------+ +-----------------+ +--------------------------+
| INPUT CONNECTOR | | MAP | | OUTPUT CONNECTOR(S) |
| | XML | (XSLT) | XML | |
| native format | -----> | rearranges the | -----> | XML to the target format |
| to XML | | XML | | one or many per map |
+-----------------+ +-----------------+ +--------------------------+
CSV, fixed width, your stylesheet CSV, fixed width, XML,
XML, IDOC, Excel Excel, socket, MQTT
- The input connector watches a folder. When a file arrives it reads it and converts it into XML. A CSV file, for example, becomes a list of rows and columns written as XML.
- The map is an XSLT stylesheet. It receives the XML from the input connector and rearranges it into the XML that the output connector needs.
- The output connector takes that XML and writes it in the target format: a CSV file, a fixed width text file, an XML file, a spreadsheet, or data sent to a network device.
Two rules are worth remembering:
- A map has exactly one input connector, so one input format.
- A map can have several output connectors. One incoming file can produce a CSV file for one system and an XML file for another at the same time.
The stylesheet never writes CSV or text itself. It always writes XML, in the layout the chosen output connector expects, and the connector does the final conversion. Those layouts are listed on the Connectors page, and Creating a Map walks through building a map from start to finish.
What you edit
There is no configuration screen. A map is made from two kinds of text file:
| File | Where | What it holds |
|---|---|---|
config.xml |
xml/config |
The list of maps: which folder to watch, which connector types to use, where to write the results. See Maps. |
A stylesheet (.xsl) |
xslt |
The transformation for one map. See Creating a Map and XSLT Extension Functions. |
Middleware4j reads config.xml when it starts, so restart it after changing a map.
Supported formats
The Type column is the value used in config.xml.
| Format | Type | Input | Output |
|---|---|---|---|
| ASCII fixed column text files | ASCII |
Yes | Yes |
| CSV delimited text files | CSV |
Yes | Yes |
| XML documents | XML |
Yes | Yes |
| IDOC SAP flat file IDOCs | IDOC |
Yes | No |
| Excel spreadsheets | XLS for input, EXCEL for output |
Yes | Yes |
| SOCKET send to a TCP/IP device | SOCKET |
No | Yes |
| MQTT publish to an MQTT broker | MQTT |
No | Yes |
Three more connector types move a file without converting it. Each is used as a matched pair, with the same type on the input and the output, and no stylesheet is involved.
| Purpose | Type |
|---|---|
| RAW copy or move a file to one or more folders | RAW
|
| EMAIL send a file as an email attachment | EMAIL
|
| PDF_PRINT print a PDF file on a named printer | PDF_PRINT
|
The transformation engine
Stylesheets are run by Saxon-HE 12, which supports XSLT 2.0 and 3.0. Middleware4j adds its own extension functions for padding, trimming and date conversion, and stylesheets can look up values from reference data files held next to them.
The installation includes two sets of samples:
samples/basicholds fourteen small maps, Map01 to Map14, covering each connector type. These are the maps in theconfig.xmlthat is installed, so they are ready to try as soon as the program is started.samples/advancedholds over fifty maps and their stylesheets, taken from real integrations between Commander4j and SAP, Sage, Tropos and B2MML (S95) systems. They are the best starting point for a new map of your own.
Running Middleware4j
| Mode | Description |
|---|---|
| Service | Runs in the background with no user interface. This is the normal way to run in production. See Installation Middleware4j. |
| Desktop | Opens a window listing the maps, their folders and a running count of files in and out. Useful while building and testing a map. See Middleware Example Screen. |
Every map runs independently, each checking its own input folder at its own interval.
Keeping an eye on it
- Every file received, and every stage of its conversion, is copied to
interface/log. See Seeing what happened. - Problems are reported by email to the Error distribution list, and a daily count of files processed is sent to the Monitor list. See EMAIL.
See also: Maps, Connectors, Creating a Map, Middleware4j Example Configuration, Installation Middleware4j