Skip to content

Instantly share code, notes, and snippets.

@andreasohlund
Created November 17, 2012 17:11
Show Gist options
  • Save andreasohlund/4097744 to your computer and use it in GitHub Desktop.
Save andreasohlund/4097744 to your computer and use it in GitHub Desktop.
Wrapping the existing nsb faults forwarder
using System;
using NServiceBus;
using NServiceBus.Faults;
namespace MyServerWithSLR
{
using NServiceBus.Faults.Forwarder;
public class MyOwnFaultManager : IManageMessageFailures, INeedInitialization
{
IManageMessageFailures wrappedFaultManager;
public void SerializationFailedForMessage(TransportMessage message, Exception e)
{
LogMessage("SerializationFailedForMessage");
wrappedFaultManager.SerializationFailedForMessage(message,e);
}
public void ProcessingAlwaysFailsForMessage(TransportMessage message, Exception e)
{
LogMessage("ProcessingAlwaysFailsForMessage");
wrappedFaultManager.ProcessingAlwaysFailsForMessage(message, e);
}
public void Init(Address address)
{
var forwarder = new FaultManager
{
ErrorQueue = Address.Parse("error"),
};
wrappedFaultManager = forwarder;
faultManagerFor = address;
LogMessage("Init");
}
public void Init()
{
// Enable this if you would like to use your own Fault Manager, this
// will also disable SLR
Configure.Instance.Configurer.ConfigureComponent<MyOwnFaultManager>(DependencyLifecycle.InstancePerCall);
}
void LogMessage(string message)
{
Console.WriteLine(string.Format("MyOwnFaultManager(Transport:{1}) - {0}", message, faultManagerFor));
}
Address faultManagerFor;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment