Beispiel #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();
                }
            }
        }
Beispiel #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);
        }
Beispiel #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);
            }
        }
Beispiel #5
0
 public void EndSend(IAsyncResult result)
 {
     _channel.EndSend(result);
 }
Beispiel #6
0
 public void EndSend(IAsyncResult result)
 {
     innerOutputChannel.EndSend(result);
 }
Beispiel #7
0
 void CompleteSend(IAsyncResult result)
 {
     channel.EndSend(result);
 }
Beispiel #8
0
 protected virtual void OnEndSend(IAsyncResult result)
 {
     inner.EndSend(result);
 }
 private void CompleteSend(IAsyncResult result)
 {
     _channel.EndSend(result);
 }
Beispiel #10
0
 void AsyncSendCB(IAsyncResult result)
 {
     publishQueue.EndSend(result);
     ((Message)result.AsyncState).Close();
 }