1 Reply Latest reply on Jul 12, 2017 6:08 PM by cfang

    ItemWriter to multiple outputs for beanio

    richardmoore

      I am needing to take the input records and determine whether they need to be written out or not and then writing to one or more output files using beanio.

       

      Writer: properties are a list of -

      • Resource - filename
      • Format - fixed | delimited, default is fixed length.
      • Record terminator - default is newline.
      • Resource record class - list of classes that will be written to this resource.

      I am not sure how this would be passed as a list in the properties.

       

      By making these a list you can write to multiple resource files, and multiple record classes can be written to a resource. Also, by allowing a resource record class to be in multiple resources it could be written to more than one file at a time.

       

      For instance,

      1. resource = abc.txt, classes = com.awginc.test.AbcRecord, com.awginc.test.DefRecord
      2. resource = def.txt, classes = com.awginc.test.DefRecord

      Input record results in being a -

      1. com.awginc.test.AbcRecord
      2. com.awginc.test.DefRecord

      File abc.txt contains -

      1. com.awginc.test.AbcRecord
      2. com.awginc.test.DefRecord

      File def.txt contains -

      1. com.awginc.test.DefRecord

       

      Have you considered or been asked for something like this? Do you think this would be a writer that would be of use for others?

        • 1. Re: ItemWriter to multiple outputs for beanio
          cfang

          We have this open task JBERET-315 (Implement ItemWriter that writes to multiple resources, which is the closest to what you've described above.  These are all good points we can think about when implementing this task.

           

          This processing pattern is different from other item writers we've implemented so far, in that here data items are not of the same type, and may have its own challenges, such as rollback.

           

          For  list of writer properties, I would store them in an separate file (a structured plain text should suffice, but xml or json can also be used), and pass the file path as a single batch property.  The batchelt class can then read in the file content and parse it.