WSO2良好实践,在序列中有许多服务调用

时间:2014-02-17 21:24:24

标签: wso2 soa wso2esb synapse

我正在处理需要执行以下任务的预定序列:

call GetNew data service getting possible new xml data
if xml exists
    with the xml data, get the ID and save it into a property
    call UpdateStatus data service with the parameters ID and PROCESSING
    call the ProcessOrder service passing the xml data
    if the return is success
        call the external SetStatus service with SUCCESS
    otherwise
        call the external SetStatus service with ERROR 
    call UpdateStatus data service again with the parameters ID and PROCESSING
otherwise
    do nothing

为此,我构建了以下序列:

payload -- to build a GetNew request
callout -- to call the GetNew data service
property -- to save the ID from the possible new message
filter -- verify if the ID property exists
    then
        clone
            payload -- to build a UpdateStatus PROCESSING request
            callout -- call the UpdateStatus
        xslt -- transform the XML from GetNew to the ProcessOrder
        in
            send -- to the ProcessOrder endpoint
        out
            property -- save the status of the ProcessOrder response
            payload -- to build the SetStatus request
            callout -- call the external SetStatus service with the status
        payload -- to build a UpdateStatus PROCESSED request
        callout -- call the UpdateStatus
    else
        drop

我想知道这是一个好习惯,还是我应该把它拆分成多个序列,或者用send替换标注,以及如何使用这种方法处理SoapFaults的最佳方法。

提前致谢。

1 个答案:

答案 0 :(得分:1)

在设计决策中分解许多序列。通常序列更像是一个类。如果特定序列执行特定任务,那么它在其他场景中也将具有凝聚力和高度可重用性。因此,基于通过序列执行的逻辑任务,可以更好地中断。

使用callout或send mediator取决于您尝试实现的用例。通过使调用异步,精确发送调解器与调出不同。因此,callout mediator进行阻塞调用,但是如果您需要服务的响应来继续执行序列,这将非常有用。 您可以通过以下链接获取有关这些调解器的更多详细信息。 http://docs.wso2.org/display/ESB480/Mediators

对于代理服务和序列,您可以定义故障序列以处理故障情形。有关错误处理的更多信息,请遵循http://docs.wso2.org/display/ESB480/Error+Handling

相关问题