聚合器末尾没有消息

时间:2014-01-15 14:56:09

标签: spring-integration

我有built一个Spring Integration应用程序并传输了一些消息并tried将它们与聚合器一起传送。应用程序到达Aggregator,但没有提供我想要的具体内容我不会释放该组并进入下一步。

我的问题是我的聚合器没有原始消息(来自Splitter之前)。我的聚合器定义如下

<int:aggregator input-channel="deirBoxProcessorToAggregatorChannel" 
                 ref="loggingAggregator" method="logAggregation"
                 output-channel="aggregatorToTransformer" 
                 expire-groups-upon-completion="true"/>

其中的代码如下..

public class LoggingAggregator {

private static final Logger LOGGER = Logger.getLogger(LoggingAggregator.class);

public void logAggregation(Message<File> message) {
    LOGGER.info("Have aggregated messsages. Will archive");
}

我在该方法中的信息虽然输入了,但总是null


应用程序上下文/ XML Spring Integration定义

<int:splitter input-channel="transformerToSplitterChannel" 
              ref="fileToMessageSplitter"
              output-channel="shippedSplitterToRouterChannel" 
              method="split" apply-sequence="true"/>

<!-- Now use a router to determine which Message builder these messages are sent onto -->
<int:router input-channel="shippedSplitterToRouterChannel" 
              ref="shippedToTypeRouter" />

<int:transformer input-channel="deirShippedBoxToTransformerChannel" 
               ref="shippedBoxTransformer" method="transform" output-
               channel="deirShippedTransformerToProcessorChannel"/>

<int:service-activator id="wellFormedShippedBoxProcess" 
                input-channel="deirShippedTransformerToProcessorChannel"
                output-channel="deirBoxProcessorToAggregatorChannel"
                ref="deirShippedFileProcessor" method="processBox" />

<int:service-activator id="malformedShippedBoxProcess"
                input-channel="deirMalformedShippedTransformerToProcessorChannel"
                output-channel="deirBoxProcessorToAggregatorChannel"
                ref="deirShippedFileProcessor" 
                method="processMalformedBox" />

<int:aggregator input-channel="deirBoxProcessorToAggregatorChannel" 
                ref="loggingAggregator" method="logAggregation"
                output-channel="aggregatorToTransformer" 
                expire-groups-upon-completion="true"/>

<int:transformer expression="headers.file_originalFile" 
                input-channel="aggregatorToTransformer"
                output-channel="transformerToArchiver" />

<int-file:outbound-channel-adapter id="deirArchiver" 
                channel="transformerToArchiver"
                directory="${dataexhange.springintg.refactor.archive.dir}"
                delete-source-files="true"/>

该过程一直到聚合器,但似乎没有通过TransformerOutboundChannelAdapter归档。

提前谢谢。

2 个答案:

答案 0 :(得分:1)

您的LoggingAggregator不正确。我建议你阅读Reference Manual。 您的logAggregation方法应该是这样的:

public File logAggregation(List<String> lines) {
     LOGGER.info("Have aggregated messsages. Will archive");
     // Create Files from lines
     return file;
}

这是聚合器的主要方法:获取对象列表并返回一个对象。

答案 1 :(得分:1)

Artem的回答是正确的。我错误地认为我返回aggregator的对象将是由splitter发送的类型。您可以通过调试来了解我在Artem的答案评论中实现的目标。

我确实在某个地方看到了,可能在手册中你可以实际返回一个类型,该类型可以从channel投射到aggregator

根据这种理解,我实际上可以返回Object,并强制转换为所需的类型,以便在我将在aggregator之后或作为{{1}}的一部分使用的日志对象中使用。

相关问题