Six Message Exchange Patterns
There are three MEPs to choose from:
- Datagram (IInputChannel and IOutputChannel)When using a datagram MEP, a client sends a message using a fire and forget exchange. A fire and forget exchange is one that requires out-of-band confirmation of successful delivery. The message might be lost in transit and never reach the service. If the send operation completes successfully at the client end, it does not guarantee that the remote endpoint has received the message. The datagram is a fundamental building block for messaging, as you can build your own protocols on top of it—including reliable protocols and secure protocols. Client datagram channels implement theIOutputChannel interface and service datagram channels implement the IInputChannelinterface.
- Request-Response (IRequestChannel and IReplyChannel)In this MEP, a message is sent, and a reply is received. The pattern consists of request-response pairs. Examples of request-response calls are remote procedure calls (RPC) and browser GET requests. This pattern is also known as half-duplex. In this MEP, client channels implement IRequestChannel and service channels implement IReplyChannel.
- Duplex (IDuplexChannel)The duplex MEP allows an arbitrary number of messages to be sent by a client and received in any order. The duplex MEP is like a phone conversation, where each word being spoken is a message. Because both sides can send and receive in this MEP, the interface implemented by the client and service channels is IDuplexChannel.
The three basic message exchange patterns. Top to bottom: datagram, request-response, and duplex.
Each of these MEPs can also support sessions. A session (and implementation ofISessionChannel of type ISession) correlates all messages sent and received on a channel. The request-response pattern is a stand-alone two-message session, as the request and reply are correlated. In contrast, the request-response pattern that supports sessions implies that all request/response pairs on that channel are correlated with each other. This gives you a total of six MEPs to choose from:
- Datagram
- Request-response
- Duplex
- Datagram with sessions
- Request-response with sessions
- Duplex with sessions
Nguồn: https://docs.microsoft.com/en-us/dotnet/framework/wcf/extending/choosing-a-message-exchange-pattern
Nhận xét