I have one DirectChannel(CHANNEL-ABC), Multiple producers put messages to it and there
is only one consumer of that channel.
My Application polls one folder for files in it and CHANNEL-1 is called per file.
Producer as follow.
IntegrationFlows.from("CHANNEL-1")
.handle(
...
logger.info("CHANNEL-1 flow started")
...
)
.split()
.handle(
...
)
.aggregate(...)
.handle(
...
logger.info("Aggregated")
)
.channel("CHANNEL-ABC")
.handle(
...
logger.info("CHANNEL-1 flow ended")
...
)
.get();
IntegrationFlows.from("CHANNEL-2")
.handle(
...
logger.info("CHANNEL-2 flow started")
...
)
.handle(
...
)
.channel("CHANNEL-ABC")
.handle(
...
logger.info("CHANNEL-2 flow ended")
...
)
.get();
IntegrationFlows.from("CHANNEL-3")
.handle(
...
logger.info("CHANNEL-3 flow started")
...
)
.channel("CHANNEL-ABC")
.handle(
...
logger.info("CHANNEL-3 flow ended")
...
)
.get();
Note: All CHANNEL-1, CHANNEL-2 and CHANNEL-3 are DirectChannel.
Consumer as follow.
IntegrationFlows.from("CHANNEL-ABC")
.handle(
...
logger.info("CHANNEL-ABC flow started")
...
)
.handle(....)
.handle(
...
logger.info("CHANNEL-3 flow ended")
...
)
.get();
I had put multiple files in polling folder and I have observed logs as below.
For File-1 //CHANNEL-ABC called but route after channel calling not executed
CHANNEL-1 flow started
Aggregated
CHANNEL-ABC flow started
CHANNEL-ABC flow ended
For File-2 //CHANNEL-ABC flow not executed and routed to another rout after that
CHANNEL-1 flow started
Aggregated
CHANNEL-2 flow ended
For File-3 //CHANNEL-ABC flow not executed but remaining flow does get executed
CHANNEL-1 flow started
Aggregated
CHANNEL-1 flow ended
For File-4 //CHANNEL-ABC flow not executed also remaining flow doesn't get executed
CHANNEL-1 flow started
Aggregated
Sometime it skips calling DirectChannel and sometime it calls but return flow to some other channel. I want my flow to be executed in single thread, What is the best channel choice for above scenario if not DirectChannle? And Is above mentioned behavior is expected behavior, if Yes then How can I prevent it?
Update:
I had added .log for explanation purpose only, Now I have updated the flow as well as observed result above.