问题
WSO2 ESB has Mediation Sequences and Proxy Services for implementing EAI patterns. I am currently new and couldn't distinguish when to use a Mediation Sequence or Proxy Service. Both seem to work well in most of the use cases. When should I use each?
回答1:
Sequence (Mediation Sequence) is a sequence of Mediators. A message comes into the sequence, passes through the each mediator, in the order they are located in the sequence. So a Mediation Sequence is the generic building material of WSO2 ESB.
A Mediation Sequence can be theoretically used to process any type of message (binary, JSON, XML) passes through it given that mediators can successfully process these messages.
Therefore a mediation sequence can be used to,
- Proxy the messages to/from a web service
- Proxy the messages to/from a REST service
- And many more applications.....
A Proxy Service is the special module in WSO2 ESB that is designed to fulfill the requirements of the 1. (Proxy the messages to/from a web service) Therefore a Proxy service is a specialized Mediation Sequence with the support of Web Service Endpoints.
WSO2 ESB facilitates to create Proxy Services in different ways for the different types of requirements.
e.g.:
- WSDL based proxy - Used to create a proxy service using a given WSDL
- Pass through proxy - Used to simply create a proxy service using the Endpoint URL
回答2:
If you need to proxy a service and if you need to mediate and perform different operations to the message you can use proxy services.
Sequence is a set of mediator (tree of mediators) though which you can send messages. If you consider mediator as building units, you can add them in a order and define it as a sequence which is reusable later. You can refer the sequence inside the proxy service and let the message flow through mediators defined in the sequence.
At high level proxy is also apparently a service to a service consumer but it actually call the actual endpoint to get the actual work done.
来源:https://stackoverflow.com/questions/14516623/wso2-esb-mediation-sequence-vs-proxy-service