2016-08-29 41 views
1

這是當前代碼..如何在對客戶端的響應之後提取有效負載?

@Bean 
public IntegrationFlow flowForHandlingPlainEncryptHistory() { 
    return IntegrationFlows.from(InputWithPlainEncryptHistory()) 
      .handle(ENCRYPT_HISTORY_SERVICE, EXTRACT_ENCRYPT_HISTORY) 
      .channel(outputWithPlainStringOfXml()).get(); 
} 

方法,在ENCRYPT_HISTORY
的插入DB工作,並返回成功。

但是,爲了提高速度
無條件返回成功,然後嘗試插入一個數據庫。

@Bean 
public IntegrationFlow flowForHandlingPlainEncryptHistory() { 
    return IntegrationFlows.from(InputWithPlainEncryptHistory()) 
      .handle(ENCRYPT_HISTORY_SERVICE, "extractEncryptHistoryReturn") 
      .channel(outputWithPlainStringOfXml() 
      .handle(ENCRYPT_HISTORY_SERVICE, "extractEncryptHistoryInsert").get(); 
} 

@Override 
public Object extractEncryptHistoryReturn(Object payload) throws Exception { 
    log.debug("[INFO] extractEncryptHistoryReturn payload : {}", payload.toString()); 

    Map<String, Object> result = initResult(); 

    result.put(Constant.KEY_NAME_RESULT_CODE, Constant.CODE_SUCCESS); 
    result.put(Constant.KEY_NAME_RESULT_MSG, Constant.MSG_SUCCESS); 

    return result; 
} 

@Override 
@Transactional 
public void extractEncryptHistoryInsert(Object payload) throws Exception { 
    log.debug("[INFO] extractEncryptHistoryInsert payload : {}", payload.toString()); 

    Map<String, Object> params = initParam(payload); 

    try { 
     long headerInfoSeq = insertHeaderInfo(params); 
     insertHeaderAclList(headerInfoSeq, (String) params.get("ACL_COUNT"), (String) params.get("ACL_LIST")); 
    } catch (Exception e) { 
     log.debug("[ERROR] extractEncryptHistory : Insert errors in the header information and acl list. {}", e.toString()); 
    } 
} 

extractEncryptHistoryInsert來到該方法的有效載荷不是第一有效載荷。

我能做些什麼來解決它?

回答

0

您需要一個發佈訂閱頻道,每個處理器都是訂閱者。添加一個任務執行程序,以便兩個處理程序並行運行。

您可以有兩個IntegrationFlow s以相同的頻道開始或在一個IntegrationFlow bean中使用子流。