Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Copy edits

...

Code Block
flatpack:[delim|fixed]:flatPackConfig.pzmap.xml[?options]

or Or for a delimited file handler with no configuration file just use

Code Block
flatpack:someName

Examples

  • flatpack:fixed:foo.pzmap.xml creates a fixed width endpoint using the foo.pzmap.xml file configuration
  • flatpack:delim:bar.pzmap.xml creates a delimited endpoint using the bar.pzmap.xml file configuration
  • flatpack:foo creates a delimited endpoint called foo with no file configuration
[?options]

You can append query options to the URI in the following format, ?option=value&option=value&...

URI Options

Name

Default Value

Description

delimiter

','

The default character delimiter for delimited files.

textQualifier

'"'

The text qualifier for delimited files.

ignoreFirstRecord

true

Whether the first line is ignored for delimited files (for the column headers).

splitRows

true

As of Camel 1.5, the component can either process each row one by one or the entire content at once.

Examples

  • flatpack:fixed:foo.pzmap.xml creates a fixed-width endpoint using the foo.pzmap.xml file configuration.
  • flatpack:delim:bar.pzmap.xml creates a delimited endpoint using the bar.pzmap.xml file configuration.
  • flatpack:foo creates a delimited endpoint called foo with no file configuration.

Message Headers

Camel will store the following headers on the IN message:

Header

Description

camelFlatpackCounter

The current row index. For splitRows=false the counter is the total number of rows.

...

The component delivers the data in the IN message as a org.apache.camel.component.flatpack.DataSetList object that have has converters for java.util.Map or java.util.List.
Usually you want the Map if you process one row at a time (splitRows=true). And the Use List for the entire content (splitRows=false), where each element in the list is a Map.
Each Map contain contains the key for the column name and its corresponding value.

...

Code Block
java
java
  Map row = exchange.getIn().getBody(Map.class);
  String firstName = row.get("FIRSTNAME");

However, you can also always get it as a List (even for splitRows=true). The same example:

Code Block
java
java
  List data = exchange.getIn().getBody(List.class);
  Map row = (Map)data.get(0);
  String firstName = row.get("FIRSTNAME");

...

In Camel 1.5 onwards the header and trailer notions in Flatpack is are supported. However it is required that , you must use fixed record id namesIDs:

  • header for the header record (must be lowercase)
  • trailer for the trailer record (must be lowercase)

...

A common use case is sending a file to this endpoint for further processing in a separate route. For example...:

Code Block
  <camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
    <route>
      <from uri="file://someDirectory"/>
      <to uri="flatpack:foo"/>
    </route>

    <route>
      <from uri="flatpack:foo"/>
      ...
    </route>
  </camelContext>

You can also convert the payload of each message created to a Map for easy Bean Integration

Include Page
CAMEL:Flatpack DataFormat
CAMEL:Flatpack DataFormat

...