Exemplo n.º 1
0
        public void EndWaitForReply(IAsyncResult result)
        {
            CorrelatorAsyncResult car = (CorrelatorAsyncResult)result;

            result.AsyncWaitHandle.WaitOne(); // todo: this should have a timeout
            unregister(car.CorrelationId);
        }
Exemplo n.º 2
0
        // Todo: need expiration support
        public IAsyncResult BeginWaitForReply(string correlationId, AsyncCallback callback, object o)
        {
            CorrelatorAsyncResult result = new CorrelatorAsyncResult(correlationId, callback, o);

            register(correlationId, result);
            return(result);
        }
Exemplo n.º 3
0
        // Todo: do we need to support wait for multiple deliveries?
        public void Reply(string correlationId, MessageDelivery delivery)
        {
            IAsyncResult result;

            _replies.TryGetValue(correlationId, out result);

            if (result != null)
            {
                CorrelatorAsyncResult  car        = (CorrelatorAsyncResult)result;
                List <MessageDelivery> deliveries = new List <MessageDelivery>();
                deliveries.Add(delivery);
                car.Complete(new ReadOnlyCollection <MessageDelivery>(deliveries));
            }
        }
        public MessageDelivery[] PublishTwoWay(PublishRequest publishRequest, TimeSpan timeout)
        {
            CorrelatorAsyncResult result = null;

            string correlationId = GetResponseCorrelationId(publishRequest);

            using (TransactionScope ts = new TransactionScope())
            {
                result = (CorrelatorAsyncResult)_correlator.BeginWaitForReply(correlationId, null, null);
                deliverToSubscriptionEndpoint(timeout, publishRequest);
                ts.Complete();
            }

            _correlator.EndWaitForReply(result);
            return(result.Results.ToArray());
        }