Announcement Announcement Module
Collapse
No announcement yet.
Write data to different outputs Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Write data to different outputs

    Hi All.

    I have a question about complex batch functionality.
    I need to implement following workflow using batch framework:

    1. Query: select type_id from record_type;
    2. For each type_id do:
    a. select Name from records where type_id = :type_id..
    b. select Name from old_records where type_id = :type_id..
    c. Write data from both queries to file "records_type_id.txt".

    So then I have separate files for each type and I don't know how much types are in database and how much records of each type exist.

    How should I do such job?
    Thanks in advance.

  • #2
    For your reading the record_type could have a look at JdbcCursorItemReader.

    For processing you could try to implement an ItemProcessor that processes the record_type into an object that holds you queried data (step 2).

    For writing you might use a FlatFileItemWriter with scope="step" and have a Listener update the filename in the executioncontext and then configure the writer to take the filename from the executioncontext like so:

    Code:
    <property name="resource" value="#{stepExecutionContext['resource']}"></property>
    I guess your commit-interval should be 1 in the case of writing each record into a seperate file.

    Comment

    Working...
    X