Can anyone please explain me the difference between the class mediator and custom handler in detail, what use cases these two mediators are used
-
Possible duplicate of [wso2 - handlers and sequence](http://stackoverflow.com/questions/35592712/wso2-handlers-and-sequence) – Kjata30 Nov 28 '16 at 15:28
1 Answers
Existing handlers are executed first in the request flow. Mediation sequences are executed after that. But if you write a custom handler, you can put it after mediation sequences as well, because mediation sequences are also executed by a handler (APIManagerExtensionHandler). So if you place your handler after APIManagerExtensionHandler, it will execute after mediation sequences.
One main difference between a class mediator and a handler is that handlers are executed in both request flow and response flow, and you can write 2 logics for those 2 cases in the same handler. But a class mediator has only a single section (i.e. mediate() method). When you engage a class mediator in a sequence, you can decide if you want to put it in request flow or response flow, or in both.
If your logic is not complex, you can use existing mediators instead of writing a class mediator. In that case, you don't need to write any java code.
You may read this as well.