Issue
The above error occurred in an Orchestration, in which following scenario was to be orchestrated:
The process gets started after receiving message over the RequestResponse port (HTTP based) followed by transformation to the destination format and sending out the transformed message to destination system.
If all is ok then response message is to be sent back to RequestResponse with status as Processed and if something goes wrong then response message is to be sent back to RequestResponse with status as Failed and Error message.
Based on this, below Orchestration is designed:
As an exception was to be handled so Scope with TransactionType None was added followed by Exception Handler.
So flow looked simple and straight forward:
All looked good, until it was compiled and error was notified.
1. Receive Input Message
2. Transform to destination format
3. Send transformed message to destination system
4. Construct response message and send Positive response back
5. If an exception occurs in above steps then catch it in Exception Handler
6. Construct response message and send negative response back including exception message
Why it happened:
As can be interpreted from error message, there was mismatch found in the number of Request received to the number of Responses sent to the RequestResponse port.Although the flow logically appears correct but syntactically it is not. RequestResponse port requires a pair (one receive and one response) to get successfully validated, so while compiling when first send shape (connected to response operation) is found it gets validated (for compiler pair is completed).
And going down in Exception block when second send shape (connected to response operation) is found it throws an error as no matching receive shape is found to complete the pair.
What to do:
In actual, there is if else situation depending on which Response message is to be sent with respective status associated with it.And even compiler loves this segregation as only one condition at a time will be true thus only one pair will form which is valid.
Below is the redesigned Orchestration:
The changes done :
1. Added a Boolean variable _exceptionOccurred initialized with false.
2. In Exception block _exceptionOccurred is set to true, so whenever exception occurs the variable will be true
3. Then Decide shape is placed under Exception block
4. So if value of variable is false(NoException) then Response message with status processed ok is constructed and sent to requestresponse port
5. And if value of variable is true then Response message with status failed is constructed and sent to requestresponse port
Wondering if there is any other way to handle this scenario?
The another approach is -- Must receive before sending a message whose messagetype corresponds to a requestresponse operation on an implemented port(Second approach)
If you have questions or suggestions, feel free to do in comments section below !!!
Do share if you find this helpful .......
Knowledge Sharing is Caring !!!!!!
Not handles such scenario but will sure help to handle such scenario
ReplyDeleteHi,
ReplyDeleteIf i am working on this scenario i would connect the success response send shape to the response port operation and construct a fault message in the catch block and connect fault to a fault on the port.
Thanks
Can you please explain me what is _exceptionMessage?
ReplyDelete_exceptionMessage is a variable to which I assign the message (exception message) from the exception object. So if you see systemEx is the object of type System.Exception and whenever there will be any exception this object will get its properties (ie., Message,InnerException etc) populated with respect to the exception occurred.
ReplyDeleteThus systemEx.Message gives me the exception message and that I have assigned to the _exceptionMessage variable which I later use to update the status field which denotes success or exception .
I had read this blog long back but today when I was facing the same issue, couldn't recall it.
ReplyDeleteVery well written blog.
Thanks.
I have read this blog long back but today when I faced this issue couldn't recall it.
ReplyDeleteVery nicely written blog.
Keep Blogging :)
Thanks,
Prashant Singh