Skip to content

Commit

Permalink
Fault manager causes process to exit if error queue was deleted, inst…
Browse files Browse the repository at this point in the history
…ead of getting stuck in an endless loop as before.
  • Loading branch information
udidahan committed Sep 8, 2011
1 parent 702c38c commit 6caf290
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
using System.Text;
using System.Security.Principal;
using NServiceBus.Installation;
using NServiceBus.Utils;

Expand Down
19 changes: 18 additions & 1 deletion src/impl/faults/NServiceBus.Faults.Forwarder/FaultManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

using System.Diagnostics;
using System.Threading;
using Common.Logging;

namespace NServiceBus.Faults.Forwarder
{
using System;
Expand Down Expand Up @@ -32,7 +36,18 @@ private void SendFailureMessage(TransportMessage message, Exception e, string re
{
SetExceptionHeaders(message, e, reason);
var sender = Configure.Instance.Builder.Build<ISendMessages>();
sender.Send(message, this.ErrorQueue);
try
{
sender.Send(message, ErrorQueue);
}
catch (QueueNotFoundException ex)
{
Logger.FatalFormat("Could not forward failed message to error queue '{0}' as it could not be found. Process wil now exit.", ex.Queue);

Thread.Sleep(10000); // so that user can see on their screen the problem
Process.GetCurrentProcess().Kill();
}

}

private static void SetExceptionHeaders(TransportMessage message, Exception e, string reason)
Expand Down Expand Up @@ -61,5 +76,7 @@ private static void SetExceptionHeaders(TransportMessage message, Exception e, s
/// Indicates of exceptions should be sanitized before sending them on
/// </summary>
public bool SanitizeProcessingExceptions { get; set; }

private static ILog Logger = LogManager.GetLogger("NServiceBus");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Common.Logging">
<HintPath>..\..\..\..\lib\Common.Logging.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="NServiceBus, Version=2.1.0.0, Culture=neutral, PublicKeyToken=9fc386479f8a226c, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\build\output\NServiceBus.dll</HintPath>
Expand Down

0 comments on commit 6caf290

Please sign in to comment.