Asynchronous Messaging
HydraExpress supports both synchronous and asynchronous messaging. Whether a message is synchronous or asynchronous may be defined at two levels: at the service level or the transport level. For example, the message patterns one-way and notification are inherently asynchronous since they require no return message. However, certain transports (such as HTTP) are inherently synchronous because they require an acknowledgment of receipt, forcing the client proxy to block until this acknowledgment is received.
This chapter discusses creating synchronous and asynchronous messages based on the service level, unless otherwise noted.
In a typical synchronous process, the client sends a request to the server and the server responds. The requestor, or client, blocks and waits for the response. This process works well when the server response is immediate. However, if the response is delayed, client execution must halt until it arrives.
In an asynchronous process, the client can perform other work while waiting for a response that may be delayed. HydraExpress accomplishes this by returning an asynchronous handle to the client that runs a thread in the background, allowing the client to continue execution until the response is ready.
Creating an asynchronous client is easy: you simply build your client using the asynchronous service operation methods provided by the proxy rather than the synchronous ones.
The following sections examine in more detail how to build asynchronous clients for any message pattern, and how to implement the notification and one-way message patterns in your service.