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