示例#1
0
        private void SendMessage(IOutputChannel channel, string action, bool commit)
        {
            using (TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew))
            {
                Message message = Message.CreateMessage(MessageVersion.Default, action);

                if (this.Parameters.AsyncSend)
                {
                    IAsyncResult result = channel.BeginSend(message, null, null);
                    channel.EndSend(result);
                }
                else
                {
                    channel.Send(message);
                }

                if (commit)
                {
                    ts.Complete();
                }
                else
                {
                    Transaction.Current.Rollback();
                }
            }
        }
示例#2
0
        private void SendMessages(TimeSpan channelTimeout, TimeSpan messageSendTimeout)
        {
            ChannelFactory <IOutputChannel> channelFactory =
                new ChannelFactory <IOutputChannel>(Util.GetBinding(), Queue);
            IOutputChannel proxy = channelFactory.CreateChannel();

            IAsyncResult[] resultArray = new IAsyncResult[MessageCount];

            for (int i = 0; i < MessageCount; i++)
            {
                Message toSend = Message.CreateMessage(MessageVersion.Default, string.Empty, i);
                resultArray[i] = proxy.BeginSend(toSend, messageSendTimeout, null, null);
            }

            for (int j = 0; j < MessageCount; j++)
            {
                proxy.EndSend(resultArray[j]);
            }

            IAsyncResult iocCloseResult = proxy.BeginClose(channelTimeout, null, null);

            Thread.Sleep(TimeSpan.FromMilliseconds(50.0)); // Dummy work
            proxy.EndClose(iocCloseResult);

            IAsyncResult chanFactCloseResult = channelFactory.BeginClose(channelTimeout, null, null);

            Thread.Sleep(TimeSpan.FromMilliseconds(50.0)); // Dummy work
            channelFactory.EndClose(chanFactCloseResult);
        }
示例#3
0
 void CompleteSend(IAsyncResult result)
 {
     try
     {
         outputChannel.EndSend(result);
         outputChannel.Close();
     }
     finally
     {
         outputChannel.Abort();
     }
 }
        public SendAsyncResult(IOutputChannel innerChannel, Message message, TimeSpan timeout, AsyncCallback onSendDone, AsyncCallback callback, object state, DependencyTelemetry telemetry)
            : base(onSendDone, callback, state, telemetry)
        {
            this.InnerChannel = innerChannel;
            this.RequestId    = message.Headers.MessageId;

            this.OriginalResult = innerChannel.BeginSend(message, timeout, OnComplete, this);
            if (this.OriginalResult.CompletedSynchronously)
            {
                innerChannel.EndSend(this.OriginalResult);
                this.Complete(true);
            }
        }
示例#5
0
 public void EndSend(IAsyncResult result)
 {
     _channel.EndSend(result);
 }
示例#6
0
 public void EndSend(IAsyncResult result)
 {
     innerOutputChannel.EndSend(result);
 }
示例#7
0
 void CompleteSend(IAsyncResult result)
 {
     channel.EndSend(result);
 }
示例#8
0
 protected virtual void OnEndSend(IAsyncResult result)
 {
     inner.EndSend(result);
 }
 private void CompleteSend(IAsyncResult result)
 {
     _channel.EndSend(result);
 }
示例#10
0
 void AsyncSendCB(IAsyncResult result)
 {
     publishQueue.EndSend(result);
     ((Message)result.AsyncState).Close();
 }