Skip to content
Advertisement

Break the Transformer flow Spring Integration

I have spring integration flows. One for the file poller and other one is to process the file

flow # 01

poll the file in C:/testing directory

files comes goes to “process” queue

flow # 02 (from “process”)

Transformer(new FindTheDepartItbelongs()) //basically file has to match to some depoartment
.transform(new FileParserTransformer()
.transformer(new CustomerTransformer()
.handle (o -> {})

The issue is if the FindTheDepartItBelongs cannot find the department then it has to stop the rest of the flow and send the message to some error queue.

If I return null from the transformer it does not work.

Is there any other way to achieve the same ?

Advertisement

Answer

A transformer cannot return null, but a .handle() method can and the flow just stops. It won’t go to the error channel, though; you have to throw an exception for that.

Advertisement