Results 1 to 4 of 4

Thread: How to generate multiple outgoing record from a single incoming record?

  1. #1

    Default How to generate multiple outgoing record from a single incoming record?

    Imagine the incoming record is as shown below which denotes that the given user has migrated from one service to another

    #user, fromService, toService
    -------------------------------------------
    user-a, quoteOfTheDay, songOfTheDay

    Now, process the record such that it generates two records;
    1- deactivate user from 'quoteOfTheDay'
    2- activate user for 'songOfTheDay'

    the required output is as below;

    #chargetype, service, user
    -----------------------------------------
    deactivate, quoteOfTheDay, user-a
    activate, songOfTheDay, user-a

    Any help is appreciated.

  2. #2

    Default

    It is as simple as to to extract user data from your input Flat File via a FlatFileItemReader<UserServiceChangeData>

    Code:
    public class UserServiceChangeData implements Serializable{
    
     private String userId;
     private String fromService;
     private String toService;
    
    }
    and your expected output to be

    Code:
    public class UserActionData implements Serializable{
    
     private String userId;
     private String service;
     private String chargeType;
    
    }
    Write an equivalent implementation for ItemProcessor<UserServiceChangeData,List<UserActio nData>> where the process method resolve a single UserServiceChangeData instance into a list of UserActionData elements and passes it to a FlatFileItemWriter<List<UserActionData>> within the scope of same chunk step

    Hope that helps

    Rahul

  3. #3

    Default

    sure that helps. thanks.

  4. #4

    Default

    To complicate the matter, I do receive records for renewals in the same file which will be processed to generate single outputs

    #user, fromService, toService
    -------------------------------------------
    user-a, quoteOfTheDay, null # for service renewals

    is it possible to mix the two?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •