Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving messages with MSMQ to the error queue with TimeToBeReceived causes the endpoint to shutdown #3378

Merged
merged 1 commit into from
Jan 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions src/NServiceBus.Core.Tests/Fakes/FakeFailureManager.cs

This file was deleted.

193 changes: 193 additions & 0 deletions src/NServiceBus.Core.Tests/Faults/FaultManagerTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
namespace NServiceBus.Core.Tests.Faults
{
using System;
using System.Collections.Generic;
using NServiceBus.Faults;
using NServiceBus.Faults.Forwarder;
using NServiceBus.ObjectBuilder;
using NServiceBus.ObjectBuilder.Common;
using NServiceBus.Settings;
using NServiceBus.Transports;
using NServiceBus.Unicast;
using NUnit.Framework;

[TestFixture]
public class FaultManagerTests
{
private IManageMessageFailures faultManager;
private FakeSender fakeSender;

[SetUp]
public void SetUp()
{
fakeSender = new FakeSender();
var settingsHolder = new SettingsHolder();
faultManager = new FaultManager(new FakeBuilder(fakeSender), new Configure(settingsHolder, new FakeContainer(), new List<Action<IConfigureComponents>>(), null));
faultManager.Init(new Address("fake", "fake"));
}

[Test]
public void SendingToErrorQueue_WhenSerializationFailedForMessage_ShouldRemoveTTBR()
{
var exception = new InvalidOperationException();
var message = new TransportMessage("id", new Dictionary<string, string>());
message.TimeToBeReceived = TimeSpan.FromHours(1);

faultManager.SerializationFailedForMessage(message, exception);

var sentMessage = fakeSender.SentMessage;
Assert.AreEqual(TimeSpan.MaxValue, sentMessage.TimeToBeReceived);
}

[Test]
public void SendingToErrorQueue_ProcessingAlwaysFailsForMessage_WhenSentFromSLR_ShouldRemoveTTBR()
{
var exception = new InvalidOperationException();
var message = new TransportMessage("id", new Dictionary<string, string>());
message.TimeToBeReceived = TimeSpan.FromHours(1);

((FaultManager) faultManager).RetriesQueue = new Address("fake", "fake");

faultManager.ProcessingAlwaysFailsForMessage(message, exception);

var sentMessage = fakeSender.SentMessage;
Assert.AreEqual(TimeSpan.MaxValue, sentMessage.TimeToBeReceived);
}

[Test]
public void SendingToErrorQueue_ProcessingAlwaysFailsForMessage_WhenRetriesQueueIsNull_ShouldRemoveTTBR()
{
var exception = new InvalidOperationException();
var message = new TransportMessage("id", new Dictionary<string, string>());
message.TimeToBeReceived = TimeSpan.FromHours(1);

faultManager.ProcessingAlwaysFailsForMessage(message, exception);

var sentMessage = fakeSender.SentMessage;
Assert.AreEqual(TimeSpan.MaxValue, sentMessage.TimeToBeReceived);
}

[Test]
public void SendingToRetriesQueue_ProcessingAlwaysFailsForMessage_ShouldRemoveTTBR()
{
var exception = new InvalidOperationException();
var message = new TransportMessage("id", new Dictionary<string, string>());
message.TimeToBeReceived = TimeSpan.FromHours(1);

var manager = (FaultManager)faultManager;
manager.RetriesQueue = new Address("retries", "fake");

faultManager.ProcessingAlwaysFailsForMessage(message, exception);

var sentMessage = fakeSender.SentMessage;
Assert.AreEqual(TimeSpan.MaxValue, sentMessage.TimeToBeReceived);
}

class FakeBuilder : IBuilder
{
private readonly FakeSender sender;

public FakeBuilder(FakeSender sender)
{
this.sender = sender;
}

public object Build(Type typeToBuild)
{
throw new NotImplementedException();
}

public T Build<T>()
{
return (dynamic) sender;
}

public IEnumerable<object> BuildAll(Type typeToBuild)
{
throw new NotImplementedException();
}

public IEnumerable<T> BuildAll<T>()
{
throw new NotImplementedException();
}

public void BuildAndDispatch(Type typeToBuild, Action<object> action)
{
throw new NotImplementedException();
}

public IBuilder CreateChildBuilder()
{
throw new NotImplementedException();
}

public void Dispose()
{
throw new NotImplementedException();
}

public void Release(object instance)
{
throw new NotImplementedException();
}
}

class FakeSender : ISendMessages
{
public void Send(TransportMessage message, SendOptions sendOptions)
{
SentMessage = message;
}

public TransportMessage SentMessage { get; set; }
}

class FakeContainer : IContainer
{
public void Dispose()
{
}

public object Build(Type typeToBuild)
{
return null;
}

public IContainer BuildChildContainer()
{
return null;
}

public IEnumerable<object> BuildAll(Type typeToBuild)
{
yield break;
}

public void Configure(Type component, DependencyLifecycle dependencyLifecycle)
{
}

public void Configure<T>(Func<T> component, DependencyLifecycle dependencyLifecycle)
{
}

public void ConfigureProperty(Type component, string property, object value)
{
}

public void RegisterSingleton(Type lookupType, object instance)
{
}

public bool HasComponent(Type componentType)
{
return true;
}

public void Release(object instance)
{
}
}
}
}
5 changes: 3 additions & 2 deletions src/NServiceBus.Core.Tests/NServiceBus.Core.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="NServiceBus.NewCompilerBits">
<HintPath>TestDlls\NServiceBus.NewCompilerBits.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -97,7 +98,8 @@
<Compile Include="Conventions\MessageConventionSpecs.cs" />
<Compile Include="DataBus\InMemoryDataBus.cs" />
<Compile Include="Encryption\ValidationFixture.cs" />
<Compile Include="Msmq\TimeToBeRceivedOverrideCheckerTest.cs" />
<Compile Include="Faults\FaultManagerTests.cs" />
<Compile Include="Msmq\TimeToBeRceivedOverrideCheckerTest.cs" />
<Compile Include="Serializers\XML\Issue_2796.cs" />
<Compile Include="StandardsTests.cs" />
<Compile Include="Encryption\ConfigureRijndaelEncryptionServiceTests.cs" />
Expand Down Expand Up @@ -213,7 +215,6 @@
<Compile Include="Timeout\When_pooling_timeouts.cs" />
<Compile Include="Timeout\When_receiving_timeouts.cs" />
<Compile Include="Timeout\When_removing_timeouts_from_the_storage.cs" />
<Compile Include="Fakes\FakeFailureManager.cs" />
<Compile Include="Fakes\FakeReceiver.cs" />
<Compile Include="Transport\for_the_transactional_transport.cs" />
<Compile Include="Transport\When_specifying_a_non_zero_throughput_limit.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Reflection;
using System.Transactions;
using Fakes;
using Faults;
using NServiceBus.Faults;
using NUnit.Framework;
using Satellites;
using Settings;
Expand All @@ -22,7 +22,7 @@ public abstract class SatelliteLauncherContext
public void SetUp()
{
Builder = new FuncBuilder();
InMemoryFaultManager = new Faults.InMemory.FaultManager();
InMemoryFaultManager = new NServiceBus.Faults.InMemory.FaultManager();
FakeReceiver = new FakeReceiver();

var configurationBuilder = new BusConfiguration();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using System.Transactions;
using Fakes;
using NServiceBus.Faults;
using NUnit.Framework;
using Settings;
using Unicast.Transport;
Expand All @@ -21,5 +22,23 @@ public void SetUp()

protected FakeReceiver fakeReceiver;
protected TransportReceiver TransportReceiver;

public class FakeFailureManager : IManageMessageFailures
{
public void SerializationFailedForMessage(TransportMessage message, Exception e)
{

}

public void ProcessingAlwaysFailsForMessage(TransportMessage message, Exception e)
{

}

public void Init(Address address)
{

}
}
}
}
Loading