Skip to content

Commit

Permalink
Merge branch 'hotfix-5.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Nov 4, 2014
2 parents b755c38 + a02d4d7 commit 688d6a1
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 12 deletions.
21 changes: 13 additions & 8 deletions src/NServiceBus.AcceptanceTesting/Support/ScenarioConfigSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ public ScenarioConfigSource(EndpointConfiguration configuration, IDictionary<Typ

if (type == typeof(MessageForwardingInCaseOfFaultConfig))
{
return new MessageForwardingInCaseOfFaultConfig
if (!configuration.SendOnly)
{
return new MessageForwardingInCaseOfFaultConfig
{
ErrorQueue = "error"
} as T;
}
}

if (type == typeof(UnicastBusConfig))
Expand All @@ -48,16 +51,18 @@ public ScenarioConfigSource(EndpointConfiguration configuration, IDictionary<Typ

if (type == typeof(AuditConfig))
{
if (configuration.AddressOfAuditQueue != null)
if (!configuration.SendOnly)
{
return new AuditConfig{QueueName = configuration.AddressOfAuditQueue.ToString()} as T;
}
if (configuration.AddressOfAuditQueue != null)
{
return new AuditConfig { QueueName = configuration.AddressOfAuditQueue.ToString() } as T;
}

if (configuration.AuditEndpoint != null)
{
return new AuditConfig { QueueName = routingTable[configuration.AuditEndpoint] } as T;
if (configuration.AuditEndpoint != null)
{
return new AuditConfig { QueueName = routingTable[configuration.AuditEndpoint] } as T;
}
}

}

if (type == typeof(Logging))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using NServiceBus.AcceptanceTesting;
using NServiceBus.AcceptanceTests.EndpointTemplates;
using NServiceBus.Config;
using NUnit.Framework;

public class When_sending_from_a_send_only : NServiceBusAcceptanceTest
Expand All @@ -26,13 +27,49 @@ public void Should_receive_the_message()
Assert.True(context.WasCalled, "The message handler should be called");
}

[Test]
public void Should_not_need_audit_or_fault_forwarding_config_to_start()
{
var context = new Context
{
Id = Guid.NewGuid()
};
Scenario.Define(context)
.WithEndpoint<SendOnlyEndpoint>()
.Done(c => c.SendOnlyEndpointWasStarted)
.Run();

Assert.True(context.SendOnlyEndpointWasStarted, "The endpoint should have started without any errors");
}

public class Context : ScenarioContext
{
public bool WasCalled { get; set; }

public Guid Id { get; set; }

public bool SendOnlyEndpointWasStarted { get; set; }
}

public class SendOnlyEndpoint : EndpointConfigurationBuilder
{
public SendOnlyEndpoint()
{
EndpointSetup<DefaultServer>()
.SendOnly();
}

public class Bootstrapper : IWantToRunWhenConfigurationIsComplete
{
public Context Context { get; set; }

public void Run(Configure config)
{
Context.SendOnlyEndpointWasStarted = true;
}
}
}


public class Sender : EndpointConfigurationBuilder
{
public Sender()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class ForwarderFaultManager : Feature
internal ForwarderFaultManager()
{
EnableByDefault();
Prerequisite(context => !context.Settings.GetOrDefault<bool>("Endpoint.SendOnly"), "Send only endpoints can't be used to forward received messages to the error queue as the endpoint requires receive capabilities");
Prerequisite(c => !c.Container.HasComponent<IManageMessageFailures>(), "An IManageMessageFailures implementation is already registered.");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ protected override void Configure(FeatureConfigurationContext context, string co

context.Container.ConfigureComponent<CorrelationIdMutatorForBackwardsCompatibilityWithV3>(DependencyLifecycle.InstancePerCall);
context.Container.ConfigureComponent<MsmqUnitOfWork>(DependencyLifecycle.SingleInstance);
context.Container.ConfigureComponent<MsmqDequeueStrategy>(DependencyLifecycle.InstancePerCall)
.ConfigureProperty(p => p.ErrorQueue, ErrorQueueSettings.GetConfiguredErrorQueue(context.Settings));


if (!context.Settings.GetOrDefault<bool>("Endpoint.SendOnly"))
{
context.Container.ConfigureComponent<MsmqDequeueStrategy>(DependencyLifecycle.InstancePerCall)
.ConfigureProperty(p => p.ErrorQueue, ErrorQueueSettings.GetConfiguredErrorQueue(context.Settings));
}

var cfg = context.Settings.GetConfigSection<MsmqMessageQueueConfig>();

var settings = new MsmqSettings();
Expand Down

0 comments on commit 688d6a1

Please sign in to comment.