protected override void OnAbort() { bool abortInnerChannel = false; lock (this.channelMapping) { // If all the accepted channels have been released, abort the inner channel. if (this.innerChannel != null && this.channelMapping.Count == 0) { abortInnerChannel = true; } } if (abortInnerChannel) { this.innerChannel.Abort(); } IChannelListener innerChannelListenerSnapshot = this.innerChannelListener; if (innerChannelListenerSnapshot != null) { innerChannelListenerSnapshot.Abort(); } }
private static void ReceiveMessages() { // Read messages from queue until queue is empty Console.WriteLine("Reading messages from queue {0}...", SampleManager.SessionlessQueueName); Console.WriteLine("Receiver Type: Receive and Delete"); // Create channel listener and channel using NetMessagingBinding NetMessagingBinding messagingBinding = new NetMessagingBinding("messagingBinding"); EndpointAddress address = SampleManager.GetEndpointAddress(SampleManager.SessionlessQueueName, serviceBusNamespace); TransportClientEndpointBehavior securityBehavior = new TransportClientEndpointBehavior(); securityBehavior.TokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider(serviceBusKeyName, serviceBusKey); IChannelListener <IInputChannel> inputChannelListener = null; IInputChannel inputChannel = null; try { inputChannelListener = messagingBinding.BuildChannelListener <IInputChannel>(address.Uri, securityBehavior); inputChannelListener.Open(); inputChannel = inputChannelListener.AcceptChannel(); inputChannel.Open(); while (true) { try { // Receive message from queue. If no more messages available, the operation throws a TimeoutException. Message receivedMessage = inputChannel.Receive(receiveMessageTimeout); SampleManager.OutputMessageInfo("Receive", receivedMessage); // Since the message body contains a serialized string one can access it like this: //string soapBody = receivedMessage.GetBody<string>(); } catch (TimeoutException) { break; } } // Close inputChannel.Close(); inputChannelListener.Close(); } catch (Exception) { if (inputChannel != null) { inputChannel.Abort(); } if (inputChannelListener != null) { inputChannelListener.Abort(); } throw; } }
protected override void OnAbort() { lock (base.ThisLock) { this.OnCloseOrAbort(); } IChannelListener innerChannelListener = this.InnerChannelListener; if ((innerChannelListener != null) && !this.sharedInnerListener) { innerChannelListener.Abort(); } }
protected override void OnAbort() { lock (ThisLock) { this.OnCloseOrAbort(); } IChannelListener channelListener = this.InnerChannelListener; if (channelListener != null && !sharedInnerListener) { channelListener.Abort(); } }
private void BasicChannelTestB(bool customBinding) { IChannelListener <IReplyChannel> listener = null; IReplyChannel channel = null; ManualResetEvent done = new ManualResetEvent(false); Thread t = null; try { channel = this.OpenChannel(customBinding, out listener); Assert.IsNotNull(channel); Assert.IsNotNull(listener); t = new Thread(BasicChannelTests.SubmitRequests); t.Start(done); for (var cnt = 0; cnt < TestServiceCommon.Iterations; cnt++) { RequestContext context; if (channel.TryReceiveRequest(TestServiceCommon.DefaultHostTimeout, out context)) { this.SendResponse(context); } else { Assert.Fail("TryReceiveRequest failed."); } } channel.Close(TestServiceCommon.DefaultHostTimeout); listener.Close(TestServiceCommon.DefaultHostTimeout); } catch (Exception e) { channel.Abort(); listener.Abort(); Assert.Fail("Unexpected exception: " + e); } finally { if (t != null && !done.WaitOne(TestServiceCommon.DefaultHostTimeout)) { t.Abort(); } done.Dispose(); } }
public void TransferInnerChannelListener(IChannelListener <IDuplexSessionChannel> innerChannelListener) { bool flag = false; lock (base.ThisLock) { this.innerChannelListener = innerChannelListener; if ((base.State == CommunicationState.Closing) || (base.State == CommunicationState.Closed)) { flag = true; } } if (flag) { innerChannelListener.Abort(); } }
protected override void OnAbort() { inner.Abort(); }
static void ReceiveSessionMessages() { // Read messages from queue until queue is empty: Console.WriteLine("Reading messages from queue {0}...", SampleManager.SessionQueueName); Console.WriteLine("Receiver Type: PeekLock"); // Create listener and channel using custom binding CustomBinding customBinding = new CustomBinding("customBinding"); EndpointAddress address = SampleManager.GetEndpointAddress(SampleManager.SessionQueueName, serviceBusNamespace); TransportClientEndpointBehavior securityBehavior = new TransportClientEndpointBehavior(); securityBehavior.TokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider(serviceBusKeyName, serviceBusKey); customBinding.GetProperty <IReceiveContextSettings>(new BindingParameterCollection()).Enabled = true; IChannelListener <IInputSessionChannel> inputSessionChannelListener = null; try { inputSessionChannelListener = customBinding.BuildChannelListener <IInputSessionChannel>(address.Uri, securityBehavior); inputSessionChannelListener.Open(); while (true) { IInputSessionChannel inputSessionChannel = null; try { // Create a new session channel for every new session available. If no more sessions available, // then the operation throws a TimeoutException. inputSessionChannel = inputSessionChannelListener.AcceptChannel(acceptSessionReceiverTimeout); inputSessionChannel.Open(); // TryReceive operation returns true if message is available otherwise it returns false. Message receivedMessage; while (inputSessionChannel.TryReceive(receiveSessionMessageTimeout, out receivedMessage)) { if (receivedMessage != null) { SampleManager.OutputMessageInfo("Receive", receivedMessage); // Since the message body contains a serialized string one can access it like this: //string soapBody = receivedMessage.GetBody<string>(); // Since the binding has ReceiveContext enabled, a manual complete operation is mandatory // if the message was processed successfully. ReceiveContext rc; if (ReceiveContext.TryGet(receivedMessage, out rc)) { rc.Complete(TimeSpan.FromSeconds(10.0d)); } else { throw new InvalidOperationException("Receiver is in peek lock mode but receive context is not available!"); } } else { // This IInputSessionChannel doesn't have any more messages break; } } // Close session channel inputSessionChannel.Close(); inputSessionChannel = null; } catch (TimeoutException) { break; } finally { if (inputSessionChannel != null) { inputSessionChannel.Abort(); } } } // Close channel listener inputSessionChannelListener.Close(); } catch (Exception) { if (inputSessionChannelListener != null) { inputSessionChannelListener.Abort(); } throw; } }
public void Abort() { _innerListener.Abort(); }
/// <summary> /// OnAbort event /// </summary> protected override void OnAbort() { WCFLogger.Write(TraceEventType.Verbose, "ChannelListener aborts"); innerChannelListener.Abort(); }
public void Dispose() { _listener.Abort(); }
protected override void OnAbort() { _innerListener.Abort(); }