I'm working on a scheduled sequence that need to do the following tasks:
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
For do that, I've build the following sequence:
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
I would like to know if this is a good practice, or if I should split it into many sequences, or replace the callouts by send, and how is the best way to deal with SoapFaults using this approach.
Thanks in advance.
Breaking into many sequences in a design decision. Generally sequence is more like a class. If a particular sequence does a specific task, it will be cohesive and highly reusable in other scenarios as well. So better break based on the logical task performed through the sequence.
Using callout or send mediator depends on the usecase you are trying to achieve. Precisely send mediator differs from callout by making the call asynchronous. So callout mediator makes a blocking call, but this will be useful if you need the response from the service to proceed with the sequence. You can get more details about these mediators on the following link. http://docs.wso2.org/display/ESB480/Mediators
For proxy services and sequences you can define fault sequences to handle fault scenarios. For more on error handling you can follow http://docs.wso2.org/display/ESB480/Error+Handling.