Synchronous Message Processing
As mentioned earlier, one way for an application to receive messages is to have the AMPS C# client return a MessageStream
object that can be used to iterate over the results of the command.
The MessageStream
object makes copies of the incoming messages. When there is no message available, the MessageStream
will block.
A MessageStream
will only remain active while the client that produced it is connected. If the client disconnects, the MessageStream
will continue to provide any messages that have not yet been consumed, then throw an exception.
The advantages of using a MessageStream
that it provides a simple processing model, that receiving messages from a MessageStream
does not block the client receive thread (see Understanding Threading ) and that a copy of the message is automatically made for the application.
In return for these advantages, a MessageStream
has higher overhead than Asynchronous Message Processing, it will not be resumed if the client disconnects, and, by default, it will use as much memory as necessary to hold messages coming from the AMPS server.
Last updated