Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-16402

Global variable in split

    XMLWordPrintableJSON

Details

    • Task
    • Status: Resolved
    • Major
    • Resolution: Invalid
    • None
    • None
    • came-core
    • None
    • Unknown

    Description

      When I reading csv files in split,  I need to get get field names and calculate index for each name. It's OK via groovy.

      I try to store indexes in some heades. I need it because csv file coud contain fields in arbitrary order. 

      In one file: name, ID, address...

      In other file: ID, address, name...

      <when>

      <simple>${headers[CamelSplitIndex]} == 0</simple>

      <transform>

      <groovy>

      <![CDATA[

      String[] AllData = exchange.getIn().getBody().split(';');

      //some processing

      //and store to headers for next using

      //for case name, ID, address...

      exchange.getIn().getHeaders().put("Name", NameValue); //0

      exchange.getIn().getHeaders().put("ID", IDValue); //1

      exchange.getIn().getHeaders().put("Address", AddressValue); //2
      ]]>

      </groovy>

      </transform>

      I use index for each field, to get correct value when I going to insert in database.

      But each time split (new step) read new line from csv file, headers a lost their value.

      While ${headers[CamelSplitIndex]} == 0 headers contain fields index.

      But when  ${headers[CamelSplitIndex]} > 0 all headers loose the info.

      How to create real global variables, which will be avialable in any <when> cases and slplit steps?

      Attachments

        Activity

          People

            Unassigned Unassigned
            Zelezny Evgeny
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: