Пример #1
0
  @Override
  public void write(List<? extends Message> items) throws Exception {

    List<Message> acceptItems = new ArrayList<Message>();
    List<Message> rejectItems = new ArrayList<Message>();

    for (Message item : items) {
      if (item.isValidate()) {
        acceptItems.add(item);
      } else {
        rejectItems.add(item);
      }
    }
    messageCsvItemWriter.write(rejectItems);
    messageJdbcItemWriter.write(acceptItems);
  }
  @Override
  public void write(List<? extends String> items) throws Exception {
    List<String> itemsFirst = new ArrayList<String>();
    List<String> itemsSecond = new ArrayList<String>();

    for (String item : items) {
      // catch all items
      if (readCount < (inputLineCount / 2)) {
        itemsFirst.add(item);
      } else {
        itemsSecond.add(item);
      }
      readCount++;
    }
    if (itemsFirst.size() > 0) {
      firstWriter.write(itemsFirst);
    }
    if (itemsSecond.size() > 0) {
      secondWriter.write(itemsSecond);
    }
  }