Itβs hard to say everything that happens because I donβt have all of your code, but I was able to make this thread work the way I think you wanted. BaseObjectTransformer does nothing but set the flag on objects passing through it:
... <context:component-scan base-package="net.grogscave.example" /> <channel id="inputChannel" /> <splitter ref="articleContentExtractor" input-channel="inputChannel" output-channel="splitArticleStaff" /> <channel id="splitArticleStaff" /> <payload-type-router input-channel="splitArticleStaff"> <mapping type="net.grogscave.example.domain.Article" channel="articleChannel" /> <mapping type="net.grogscave.example.domain.Staff" channel="staffChannel" /> </payload-type-router> <channel id="articleChannel" /> <transformer input-channel="articleChannel" output-channel="articleOutAggregateChannel" ref="baseObjectTransformer"/> <channel id="staffChannel" /> <transformer input-channel="staffChannel" output-channel="articleOutAggregateChannel" ref="baseObjectTransformer"/> <channel id="articleOutAggregateChannel" /> <aggregator ref="articleAggregator" input-channel="articleOutAggregateChannel" output-channel="splitArticleInChannel"/> <channel id="splitArticleInChannel" /> <splitter input-channel="splitArticleInChannel" output-channel="splitArticleOutChannel" /> <channel id="splitArticleOutChannel" /> <payload-type-router resolution-required="true" input-channel="splitArticleOutChannel"> <mapping type="net.grogscave.example.domain.Article" channel="contentOutChannel" /> <mapping type="net.grogscave.example.domain.Staff" channel="staffOutChannel" /> </payload-type-router> <channel id="contentOutChannel"> <queue capacity="10" /> </channel> <channel id="staffOutChannel"> <queue capacity="10" /> </channel> ...
Then I just execute this thread with the following code in a test case:
... AbstractApplicationContext context = new ClassPathXmlApplicationContext( "/META-INF/spring/split-agg-split.xml", SplitAggSplitTests.class); MessageChannel inputChannel = context.getBean("inputChannel", MessageChannel.class); PollableChannel contentOutChannel = context.getBean("contentOutChannel", PollableChannel.class); PollableChannel staffOutChannel = context.getBean("staffOutChannel", PollableChannel.class); inputChannel.send(new GenericMessage<String>("Dewey Wins!,A. Fool, C. Lewlis")); logger.info("==> Article recieved: " + contentOutChannel.receive(0).getPayload()); for(int i = 0; i < 2; i++) { logger.info("==> Staff recieved: " + staffOutChannel.receive(0).getPayload()); } ...
My log output displays all three objects.
All that was said, did you consider just removing the extra splitter / aggregator and just moving the setAuthors logic to your first splitter? I donβt know all the details of your flow, but it seems like it would make it easier.
source share