Spring 集成:一个聚合器,可以在处理完所有消息后释放
Spring integration: an aggregator that can release when all messages are processed
我正在构建一个调用许多不同 Web 服务的系统,我希望生成一个关于调用 ws 后返回的所有错误的报告。
为此,我使用 <int:aggregator: >
来聚合来自 error-channel
的消息,但我不知道 release-strategy
因为,我喜欢聚合错误通道的所有消息。那么我如何配置 <int:aggregator >
来聚合所有消息。
<int:aggregator
correlation-strategy-expression="'${error.msg.correlation.key}'"
input-channel="ws.rsp.error.channel"
output-channel="outboundMailChannel"
ref="errorAggregator"
method="generateErrorReport"
release-strategy-expression="false"
group-timeout="2000"
完成后过期组="true"/>
<int:service-activator
input-channel="outboundMailChannel"
ref="errorMsgAgregatedActivator"
method="handleMessage"
/>
激活器:
@ServiceActivator
public void handleMessage(Message<Collection<Object>> errorList) {
Collection<Object> payload=errorList.getPayload();
System.out.println("error list: "+payload.toString());
}
谢谢。
聚合需要适当的释放策略,或者您可以简单地使用 release-strategy-expression="false"
(从不释放),然后使用 group-timeout
在一段时间后释放组中的任何内容。
您可能希望使用常量关联 correlation-strategy-expresision="'foo'"
并设置 expire-groups-upon-completion="true"
以便新组从下一条消息开始。
我正在构建一个调用许多不同 Web 服务的系统,我希望生成一个关于调用 ws 后返回的所有错误的报告。
为此,我使用 <int:aggregator: >
来聚合来自 error-channel
的消息,但我不知道 release-strategy
因为,我喜欢聚合错误通道的所有消息。那么我如何配置 <int:aggregator >
来聚合所有消息。
<int:aggregator
correlation-strategy-expression="'${error.msg.correlation.key}'"
input-channel="ws.rsp.error.channel"
output-channel="outboundMailChannel"
ref="errorAggregator"
method="generateErrorReport"
release-strategy-expression="false"
group-timeout="2000"
完成后过期组="true"/>
<int:service-activator
input-channel="outboundMailChannel"
ref="errorMsgAgregatedActivator"
method="handleMessage"
/>
激活器:
@ServiceActivator
public void handleMessage(Message<Collection<Object>> errorList) {
Collection<Object> payload=errorList.getPayload();
System.out.println("error list: "+payload.toString());
}
谢谢。
聚合需要适当的释放策略,或者您可以简单地使用 release-strategy-expression="false"
(从不释放),然后使用 group-timeout
在一段时间后释放组中的任何内容。
您可能希望使用常量关联 correlation-strategy-expresision="'foo'"
并设置 expire-groups-upon-completion="true"
以便新组从下一条消息开始。