Spring integration Spring集成拆分器后消息丢失。数据未随机到达聚合器

Spring integration Spring集成拆分器后消息丢失。数据未随机到达聚合器,spring-integration,splitter,aggregator,Spring Integration,Splitter,Aggregator,我正在尝试并行处理SQL查询的输出。下面是我的代码。我在聚合器中有sysout。但我随机看到聚合器中的sysout没有打印出来。此外,aggregator中的发布方法也不打印系统输出。我想,我把信息丢到哪里了。有人能透露一些信息吗 <int:bridge input-channel="inputChannel" output-channel="dbRequestChannel" /> <jdbc:outbound-gateway request-cha

我正在尝试并行处理SQL查询的输出。下面是我的代码。我在聚合器中有sysout。但我随机看到聚合器中的sysout没有打印出来。此外,aggregator中的发布方法也不打印系统输出。我想,我把信息丢到哪里了。有人能透露一些信息吗

    <int:bridge input-channel="inputChannel" output-channel="dbRequestChannel" />

        <jdbc:outbound-gateway request-channel="dbRequestChannel"
            max-rows-per-poll="0" data-source="dataSource" reply-channel="headerEnricher"
            query="select empname, empno, empdob from employee where empno = 1234" />

        <int:header-enricher input-channel="headerEnricher"
            output-channel="splitterChannel">
            <int:header name="payloadSize" value="3"></int:header>
        </int:header-enricher>

        <int:chain input-channel="splitterChannel" output-channel="splitterOutputChannel">
            <int:splitter />
        </int:chain>


        <int:channel id="splitterOutputChannel">
            <int:dispatcher task-executor="sampleTaskExecutor" />
        </int:channel>

        <bean id="sampleTaskExecutor"
            class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
            <property name="corePoolSize" value="5" />
            <property name="maxPoolSize" value="10" />
            <property name="queueCapacity" value="25" />
        </bean>

        <int:service-activator input-channel="splitterOutputChannel"
            ref="springIntegrationtest" method="testMethod" output-channel="aggregatePayload">
        </int:service-activator>

        <int:aggregator input-channel="aggregatePayload"
            release-strategy-method="release" output-channel="nullChannel"
            send-partial-result-on-expiry="true" ref="springIntegrationtest"
            method="aggregateData" />

    @RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:spring-integration.xml" })
public class SpringIntegrationTest {


    @Autowired
    private MessageChannel inputChannel;

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");



    @Test
    public void testQueue() {
        Message<String> quoteMessage = MessageBuilder
                .withPayload("testPayload").build();
        inputChannel.send(quoteMessage);
    }


    public Map<String, String> testMethod(Message<?> m) {

        System.out.println(sdf.format(new Date()));
        return (Map<String, String>) m.getPayload();
    }

    public boolean release(ArrayList<Map<String, Object>> payload) {
        boolean release = false;
        int size = payload.size();
        if (size == 3) {
            release = true;
        }
        System.out.println(release);
        return release;
    }

    public Message<String> aggregateData(ArrayList<Map<String, Object>> payload) {

        System.out.println("In aggregateData " + payload);
        Message<String> quoteMessage = MessageBuilder
                .withPayload("testPayload").build();
        return quoteMessage;
    }

}

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(位置={“classpath:spring integration.xml”})
公共类SpringIntegrationTest{
@自动连线
专用消息通道输入通道;
SimpleDataFormat sdf=新的SimpleDataFormat(“yyyy-MM-dd-HH:MM:ss.SSS”);
@试验
公共void testQueue(){
Message quoteMessage=MessageBuilder
.withPayload(“testPayload”).build();
inputChannel.send(quoteMessage);
}
公共映射测试方法(消息m){
System.out.println(sdf.format(newdate());
返回(Map)m.getPayload();
}
公共布尔释放(ArrayList有效负载){
布尔释放=假;
int size=payload.size();
如果(大小==3){
释放=真;
}
系统输出打印项次(发布);
返回释放;
}
公共消息聚合数据(ArrayList有效负载){
System.out.println(“In aggregateData”+有效载荷);
Message quoteMessage=MessageBuilder
.withPayload(“testPayload”).build();
返回报价信息;
}
}

我认为您的问题在于状态和选项的组合

你有这个:

int size = payload.size();
if (size == 3) {
    release = true;
}
因此,您的聚合器将在
3
项到达后立即释放该组,同时拆分后您可能会有更多的项

release
向聚合器发出信号以完成分组并退出。默认情况下,它有一个类似于
expireGroupsUponCompletion=false的选项,这意味着将组保留在存储中,但状态为
completed


如果您的目标只是从聚合元组发出3,则应该考虑将 ExpReGrimeSopOnfult转换为<代码> Trime< /Cord>。有关更多信息,请参阅聚合器。

查询的输出始终仅返回3个结果。这就是为什么为了测试,我添加了这个条件。请提供org.springframework.integration的调试日志