Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Channels / Msmq3PoisonHandler.cs / 1 / Msmq3PoisonHandler.cs
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------
namespace System.ServiceModel.Channels
{
using System.Collections.Generic;
sealed class Msmq3PoisonHandler: IPoisonHandlingStrategy
{
const int maxTrackedMessages = 256;
MsmqReceiveHelper receiver;
SortedList trackedMessages;
object thisLock = new object();
internal Msmq3PoisonHandler(MsmqReceiveHelper receiver)
{
this.receiver = receiver;
this.trackedMessages = new SortedList(maxTrackedMessages);
}
public bool CheckAndHandlePoisonMessage(MsmqMessageProperty messageProperty)
{
long lookupId = messageProperty.LookupId;
int seen;
lock (thisLock)
{
seen = this.UpdateSeenCount(lookupId);
if (seen > (receiver.MsmqReceiveParameters.ReceiveRetryCount + 1) && receiver.MsmqReceiveParameters.ReceiveRetryCount != Int32.MaxValue)
{
FinalDisposition(messageProperty);
this.trackedMessages.Remove(lookupId);
return true;
}
}
messageProperty.AbortCount = seen - 1;
return false;
}
public void FinalDisposition(MsmqMessageProperty messageProperty)
{
switch (receiver.MsmqReceiveParameters.ReceiveErrorHandling)
{
case ReceiveErrorHandling.Drop:
this.receiver.DropOrRejectReceivedMessage(messageProperty, false);
break;
case ReceiveErrorHandling.Fault:
MsmqReceiveHelper.TryAbortTransactionCurrent();
if (null != this.receiver.ChannelListener)
this.receiver.ChannelListener.FaultListener();
if (null != this.receiver.Channel)
this.receiver.Channel.FaultChannel();
break;
default:
DiagnosticUtility.DebugAssert("System.ServiceModel.Channels.Msmq3PoisonHandler.FinalDisposition(): (unexpected ReceiveErrorHandling)");
break;
}
}
int UpdateSeenCount(long lookupId)
{
int value;
if (this.trackedMessages.TryGetValue(lookupId, out value))
{
++ value;
this.trackedMessages[lookupId] = value;
return value;
}
else
{
if (maxTrackedMessages == this.trackedMessages.Count)
{
this.trackedMessages.RemoveAt(0);
}
this.trackedMessages.Add(lookupId, 1);
return 1;
}
}
public void Open()
{}
public void Dispose()
{}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- Vector3DKeyFrameCollection.cs
- HostedAspNetEnvironment.cs
- printdlgexmarshaler.cs
- ExtensionWindowResizeGrip.cs
- DynamicPropertyHolder.cs
- WebPartConnectVerb.cs
- Point3DCollection.cs
- TextEditorTyping.cs
- BufferBuilder.cs
- Memoizer.cs
- SqlCacheDependencySection.cs
- StaticExtensionConverter.cs
- Convert.cs
- ObjectSpanRewriter.cs
- DataSourceCollectionBase.cs
- FileDialogPermission.cs
- Inflater.cs
- SerializationObjectManager.cs
- MetafileHeaderWmf.cs
- ScrollData.cs
- ArrayConverter.cs
- GridViewRowPresenter.cs
- BrushConverter.cs
- FileDialog.cs
- ActiveXContainer.cs
- PerformanceCounter.cs
- KoreanLunisolarCalendar.cs
- DynamicFilter.cs
- FieldDescriptor.cs
- Propagator.JoinPropagator.SubstitutingCloneVisitor.cs
- DataGridParentRows.cs
- CookieHandler.cs
- ControlCachePolicy.cs
- RulePatternOps.cs
- UnaryExpression.cs
- Convert.cs
- PermissionAttributes.cs
- TextInfo.cs
- ResXFileRef.cs
- XPSSignatureDefinition.cs
- XmlSchemaAttributeGroupRef.cs
- SystemMulticastIPAddressInformation.cs
- ObjectStateEntry.cs
- EntityKeyElement.cs
- ErrorsHelper.cs
- SafeReversePInvokeHandle.cs
- SamlSubject.cs
- CmsUtils.cs
- NativeMethods.cs
- ManagementBaseObject.cs
- GlyphRunDrawing.cs
- WindowsGraphicsWrapper.cs
- ReaderContextStackData.cs
- HashCodeCombiner.cs
- DocumentSchemaValidator.cs
- FormClosedEvent.cs
- ListItemCollection.cs
- X509SecurityTokenProvider.cs
- Thumb.cs
- AsyncOperation.cs
- ArraySubsetEnumerator.cs
- RecommendedAsConfigurableAttribute.cs
- RuleSettings.cs
- TypeReference.cs
- ButtonStandardAdapter.cs
- ServiceProviders.cs
- TextReader.cs
- PageSetupDialog.cs
- ImageMap.cs
- Int64AnimationBase.cs
- UpDownEvent.cs
- OdbcConnectionString.cs
- Panel.cs
- StylusButtonCollection.cs
- Debug.cs
- ApplicationException.cs
- ListDictionary.cs
- Rect3D.cs
- MeasurementDCInfo.cs
- CodeTypeDelegate.cs
- SessionEndingEventArgs.cs
- SupportsEventValidationAttribute.cs
- ReadOnlyHierarchicalDataSource.cs
- ListView.cs
- ImageListStreamer.cs
- HtmlHead.cs
- ItemCheckedEvent.cs
- OdbcConnectionPoolProviderInfo.cs
- TemplateNameScope.cs
- EventManager.cs
- PlainXmlDeserializer.cs
- Marshal.cs
- SmtpTransport.cs
- ellipse.cs
- TableLayoutPanel.cs
- SQLMembershipProvider.cs
- XmlParserContext.cs
- EndpointDiscoveryMetadata.cs
- Knowncolors.cs
- PictureBoxDesigner.cs