2016-08-05 80 views
4

我有以下結構。彈簧集成聚合器無法正常工作。

<int:publish-subscribe-channel id="updateProjectRequest" /> 
<int:channel id="aggregate-project"/> 

<int:service-activator input-channel="updateProjectRequest" output-channel="aggregate-project" ref="updateProjectResponseHandler" method="createFolder"/> 
<int:service-activator input-channel="updateProjectRequest" output-channel="aggregate-project" ref="updateProjectResponseHandler" method="createRepo"/> 

<int:aggregator input-channel="aggregate-project" ref="projectAggregator"> 

以下是我的Aggregator類。

@Component("projectAggregator") 
public class ProjectAggregator { 

@Aggregator 
public boolean aggregatingMethod(List<Map<String, List<Project>>> items) { 
//////// CODE ////// 
} 

@ReleaseStrategy 
public boolean releaseChecker(List<Message<?>> messages) { 
//////CODE///// 
} 

@CorrelationStrategy 
public Map<String, List<Project>> correlateBy(Map<String, List<Project>> item) { 
    return item; 
} 

問題是如果我打印@ReleaseStrategy方法的消息長度它始終保持1.據我所知,這應該增加。你能幫我找出上面提到的代碼有什麼問題嗎?

回答

1

如果您稍後想要彙總發送給發佈/訂閱渠道訂閱者的郵件,則需要將apply-sequence設置爲true

如果屬實,則將correlationId和序列信息添加到消息標題中。

<xsd:attribute name="apply-sequence" type="xsd:string" default="false"> 
    <xsd:annotation> 
     <xsd:documentation> 
      Specify whether the sequence size, sequence number, and correlation id 
      headers should be set on 
      Messages that are sent through this channel. 
     </xsd:documentation> 
    </xsd:annotation> 
</xsd:attribute>