Invoke a policy without affecting the flow

In my usecase , I need to trigger an email to DL in case of error scenerios by calling a REST service irrespective of the main flow.

Implementation done in my proxy (Default fault Rule section).

1. Assign message to define my error template

2. A service callout to call the email trigger service.

3. Raise fault to throw error

Queries

- Best way to trigger email without affecting the actual flow ?

- Any options like fire and forget so that it will not affect the actual error flow?

- what if the email trigger service callout failed?

Eg : If my usecase returns 401 unauthorized

Scenerio 1 : If email trigger Service callout is 200 Success - 401 unauthorized will be returned to the user

Scenerio 2 : If email trigger Service callout is 4xx Failure - then 4xx Failure message will be returned to the user (which is not the expected result as error message to the user should be 401 unauthorized)

Help with the best approach !

0 4 317
4 REPLIES 4

I think you want to explore making the service callout to the email service via JavaScript instead of the service callout policy. You can make that call asynchronously to "fire-and-forget" and ignore the response of the the service callout, leaving the back-end error returning to the user.

yes, and see this Q&A for a fire-and-forget approach using JS.

Hi @maivizhi,

You can make use of ServiceCallout policy without <Response> tag in it.

If <Response> element is not specified, the API proxy does not wait for response to be completely read and executes the message flow steps. Also, the response from the target is not available so there is no way to access the response.

Refer to ServiceCallout - Fire Away

@Aswin Segu Thanks for this suggestion. We tried using it and it works well!