Announcement Announcement Module
Collapse
No announcement yet.
How to generate multiple outgoing record from a single incoming record? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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

    Comment


    • #3
      sure that helps. thanks.

      Comment


      • #4
        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?

        Comment

        Working...
        X