Open mhdirkse opened 1 year ago
Perhaps it would help if you would show us how you configured your HttpSender. Each status code can be used as a forward, success (200/201/202/204/206) it is also possible to treat follow redirects (301/302/307) as success. Other status codes will use the statuscode as the name of the foward (if this forward exists).
This is how I am trying to get along:
<Json2XmlInputValidator name="ValidatePost"
schema="CreeerZaak_LK01/xsd/ZgwZaak.xsd"
root="ZgwZaak"
outputFormat="JSON"
deepSearch="true"
throwException="true"
/>
<HttpSender name="PostZgwZaakSender"
methodType="POST"
headersParams="Authorization,Accept-Crs,Content-Crs,Accept"
url="${zgw.baseurl}${zgw.endpoint.zaak}"
timeout="${creeerZaak.timeout}"
maxExecuteRetries="5"
contentType="application/json">
<Param name="Accept-Crs" value="EPSG:4326" />
<Param name="Accept" value="application/json" />
<Param name="Content-Crs" value="EPSG:4326" />
<Param name="Authorization" value="Bearer ${JwtToken}" />
</HttpSender>
<Forward name="success" path="JsonToXml" />
</SenderPipe>
<EchoPipe name="FailPostZgwZaakSender">
<Forward name="success" path="EXCEPTION"/>
</EchoPipe>
<JsonPipe name="JsonToXml"
storeResultInSessionKey="PostZgwZaakResult">
<Forward name="success" path="UnwrapOpenZaakApiEnvelopeToSingle" />
</JsonPipe>
I hoped that the success
forward would only be followed for 2xx response codes. In any other case I expected a default behavior of taking the next pipe, which is the <EchoPipe>
in this example.
I have F!F version 7.9-20230214.195451.
The following code does what I want:
<SenderPipe name="PostZgwZaak">
<Json2XmlInputValidator name="ValidatePost"
schema="CreeerZaak_LK01/xsd/ZgwZaak.xsd"
root="ZgwZaak"
outputFormat="JSON"
deepSearch="true"
throwException="true"
/>
<HttpSender name="PostZgwZaakSender"
methodType="POST"
headersParams="Authorization,Accept-Crs,Content-Crs,Accept"
url="${zgw.baseurl}${zgw.endpoint.zaak}"
timeout="${creeerZaak.timeout}"
maxExecuteRetries="5"
contentType="application/json">
<Param name="Accept-Crs" value="EPSG:4326" />
<Param name="Accept" value="application/json" />
<Param name="Content-Crs" value="EPSG:4326" />
<Param name="Authorization" value="Bearer ${JwtToken}" />
</HttpSender>
<Forward name="success" path="JsonToXml" />
<Forward name="exception" path="FailPostZgwZaakSender" />
</SenderPipe>
<EchoPipe name="FailPostZgwZaakSender">
<Forward name="success" path="EXCEPTION"/>
</EchoPipe>
<JsonPipe name="JsonToXml"
storeResultInSessionKey="PostZgwZaakResult">
<Forward name="success" path="UnwrapOpenZaakApiEnvelopeToSingle" />
</JsonPipe>
@nielsm5, I understand your remark that any 2xx HTTP code results in forward "success" while any other code results in forward "exception" provided that this forward is in the SenderPipe. The explanation of forward "exception" is very confusing to me. It says: "an exception was caught when processing the message". This suggests a Java exception. @nielsm5, you indicated that the "exception" forward is followed if any (very) unhappy situation is encountered, the definition of "unhappy" depending on the type of pipe. I would document this differently.
Just to clarify, the name is meant to represent 'anomaly / irregularity and deviation', the opposite of success. You are assuming it has something to do with a Java Exception. While this forward will also be used in such a scenario, but it is not limited to just Java Exceptions.
Describe the issue I have a HttpSender and I want to handle errors indicated by a negative HTTP response code. The HttpSender provides a forward for every possible HTTP code, but implementing all these forwards introduces a lot of boilerplate code. I also looked at the forwards provided by the SenderPipe, but I did not see a forward that would be triggered by a 4xx or 5xx response code. I tried to give my SenderPipe only a "success" forward and putting a pipe below that for the error handling. This did not work because the success forward was also followed for a 5xx response code.
After discussing with Jaco de Groot I propose that the following features are added:
notFoundForwardName
can be added to the SenderPipe. The forward named in that attribute should be followed if the SenderPipe has<Forward>
tags that correspond to forwards implemented by the sender, but none of them applies for the result of the sender. For a HttpSender for example, this means: If the SenderPipe has forwards "200", "201", "202" but the HTTP result code is "400", then the not found forward should be followed.With these changes, you could give the SenderPipe two forwards "2xx" and "notFound" where the "notFound" forward should be the value of attribute
notFoundForwardName
.Reporter Martijn Dirkse
To Reproduce Steps to reproduce the behavior:
Screenshots If applicable, add screenshots to help explain your problem.
Configuration
Input
Environment
Additional Environment
Additional Context The context of this issue is the ZaakBrug project. I have a HttpSender that issues requests to OpenZaak. I want to add simple error handling: a single flow for any error response from OpenZaak.