I'm developing a mule work-flow to insert a record into the database, trying to catch the exception in case if the record is already present and send the HTTP status (409-Conflict) and the back to the client.
<when expression="#[message.inboundProperties['http.method'] == 'POST']">
<json:json-to-object-transformer returnClass="java.lang.Object" doc:name="JSON to Object" />
<set-variable variableName="id" value="#[message.payload.id]" doc:name="Save brandId"/>
<json:object-to-json-transformer doc:name="Object to JSON"/>
<db:insert config-ref="Postgres" doc:name="Configstore">
<db:parameterized-query><![CDATA[INSERT INTO messages("id", "data") VALUES ( #[flowVars['id']], CAST(#[message.payload] as json))]]> </db:parameterized-query>
</db:insert>
<logger message="REST Response = #[message.payload]" level="INFO" doc:name="LOG Rest Response"></logger>
<choice-exception-strategy name="Global_Choice_Exception_Strategy" doc:name="Global Choice Exception Strategy">
<catch-exception-strategy doc:name="Catch_Exception_Strategy" when="#[exception.causedBy(org.postgresql.util.PSQLException)]">
<set-payload value="The request cannot be processed, the error is #[exception.getExceptionPayload()]"/>
<set-property propertyName="http.status" value="404"/>
<http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" method="POST" doc:name="HTTP"/>
</catch-exception-strategy>
</choice-exception-strategy>
</when>
The start-up is repeatedly failing and the following error reported in the logs.
cvc-complex-type.2.4.a: Invalid content was found starting with element 'choice-exception-strategy'. One of '{"http://www.mulesoft.org/schema/mule/core":abstract-message-processor, "http://www.mulesoft.org/schema/mule/core":abstract-outbound-endpoint, "http://www.mulesoft.org/schema/mule/core":abstract-mixed-content-message-processor}' is expected. at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) ~[?:?]
This error alternatively reported for both choice-exception-strategy and catch-exception-strategy. Not sure what's invalid here or need to define a custom message-processor or outbound-endpoint. I'm using mule EE-3.8.0
</flow>
like. <choice-exception-strategy doc:name="Global_Choice_Exception_Strategy"> <catch-exception-strategy when="#[exception.causedBy(org.postgresql.util.PSQLException)]" doc:name="Catch_Exception_Strategy"> <set-payload value="The request cannot be processed, the error is #[exception.getExceptionPayload()]" doc:name="Set Payload"/> ..... </catch-exception-strategy> </choice-exception-strategy> </flow>. If you are using Intellji GUI will be missing. – star