예제 #1
0
        /// <summary>Sends a request message and waits for a reply.</summary>
        /// <param name="request">The message to send</param>
        /// <returns>The reply message</returns>
        /// <exception cref="TimeoutException">Thrown when the message has not been received by the target processor before <see cref="TimeToBeReceived"/></exception>
        /// <exception cref="AcknowledgmentException">Thrown when the message cannot be delivered to the destination queue</exception>
        public Message SendRequest(Message request)
        {
            Contract.Requires(request != null);
            Contract.Ensures(Contract.Result <Message>() != null);

            SetupRequest(request);
            var tracking = _postman.RequestDelivery(request, _requestQueue, null);

            _postman.WaitForDelivery(tracking);
            _postman.WaitToBeReceived(tracking);
            return(_responseQueue.ReadByCorrelationId(request.Id));
        }