Announcement Announcement Module
Collapse
No announcement yet.
Composite Item Writer as per condition Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Composite Item Writer as per condition

    Hi,

    I have used JdbcCursorItemReader to read records from the database and want to use Composite ItemWriter to write the data into different files as per one status column.

    Means record should goto different files as per the status column,


    Please help me .........

    Thanks...

  • #2
    The basic pattern is this:

    Code:
    class MyCompositeItemWriter extends ItemWriter<Object> {
      private ItemWriter writer1;
      private ItemWriter writer2;
    
      public void write(List<? extends Object> items) {
         for(Object item : items){
            if(writeToFirst(item)){
              this.writer1.write(Arrays.asList(item));
            }
            else{
              this.writer2.write(Arrays.asList(item));
            }
         }
      }
    }

    Comment

    Working...
    X