1

Content based routing and java batch JSR 352 (jBeret, Spring Batch)?

Have tried to implement some simple "real world" batch jobs because the "hello world" was looking promising. Seems that I haven't got the concept right - but the actual release seam pretty useless for "real world" examples.

- read 5mio lines (ItemReader works fine)
- write to three different filed/resources based on the content of the line read

The "intuitive" way would be to:

  • configure three writer (e.g. ItemWriterA, ItemWriterB, ItemWriterC). BUT: onle one writer is possible in a chunks - why this restriction?

  • add a decision and use the writer based on your decision. BUT: decisions can't be included in cunks - why this restriction?

What's the right approch doing this with Java Batch JSR 352? Any hints are welcome.

Java Batch - as could be

Jens Piegsa
  • 7,399
  • 5
  • 58
  • 106
unclescrouge
  • 403
  • 5
  • 10

1 Answers1

1

You would need to implement the logic in a single ItemWriter. The specification-defined framework doesn't help you here. SpringBatch has a CompositeItemWriter which helps with this sort of use case, though it is specific to SpringBatch and won't work with other JSR 352 implementations like Liberty (or, as far as I know, JBeret).

One rationale for not including "child writers" in the spec was, as in your case, the idea that there'd be app-specific logic to decide to write (or not) to the children. But it's an area where JSR 352 could use more samples and probably enhancement of the spec itself.

That's not a great answer, but I didn't want to leave the question without an answer.

Scott Kurz
  • 4,985
  • 1
  • 18
  • 40
  • Thanks for your confirmation. That was what i was expecting. In other words - another useless JSR - for "real world" programming. – unclescrouge Jan 25 '18 at 10:26
  • Have found some other things that are missing in the JSR wihle playing around - and confirming that the approach is fine but a lot of things are missing and theres no possibility to do a workaround. - Batchlet that calls – unclescrouge Jan 25 '18 at 10:30
  • If someone has the need to do more "real world" things see this solutions to get some ideas how JSR 352 could have worked. *** Data Pipeline - Express Free (10,000 Records / Job) .. in another option (not free version). https://northconcepts.com/ Lightweight ETL Framework for Java *** Pentaho Data Integration - Java API https://wiki.pentaho.com/display/EAI/Pentaho+Data+Integration+-+Java+API+Examples call a transformation or a job from another Java program – unclescrouge Jan 25 '18 at 10:44