I have a batch job I’m working on. I have my proce...
# spring
m
I have a batch job I’m working on. I have my processor returning a
Pair
, and a
CompositeItemWriter
that sends half the pair to each of two individual writers. But if something goes wrong, I only want to write to one: normally you can return null from a processor and nothing gets written, but if I return
Pair(object1, null)
, then the writer that receives the null gives me a
Target object must not be null
. Am I approaching this the wrong way, or is there a way around this?
p
I am not sure you can solve this
📯 1
m
Batch is an endless struggle to me as I try to find some way to crowbar whatever I need to happen into its [unintuitive-to-me] requirements.
p
I built a huge system in Spring Batch so I feel your pain.. I use java config for everything and keep finding documentation for XML setup
I don't even need to use the automatic recovery and restarts so if I could start all over I would stay far away from Spring Batch.. Too complex for little benefit
m
I’ve experienced the same (all google results are in xml.) I’m getting better at intuiting my way past some rough parts, but then things like this. sigh.
p
null
has a special meaning for batch because it's a mark of end of input.. so you can't easily "skip" the null because then it won't know when to finish
you could solve it by sending some sort of blank value ("null object") which your writer will have a special check for
m
I’m going to try returning a
ClassifierCompositeItemWriter
, and based on if the send thing is null, either return the CompositeWriter or the single Writer.
t
The version of Spring Batch that got released this year changed the docs to have a toggle between java and xml .
The Docs are much better now.
👍🏼 1