Permalink
Browse files

Fixed redundant logging module registration

  • Loading branch information...
1 parent a8b5bda commit dd9598f8ed8bbb5bd83941f1c630c67b557af49e @CoreyKaylor CoreyKaylor committed Oct 12, 2012
View
4 Rhino.ServiceBus.StructureMap/StructureMapBuilder.cs
@@ -138,8 +138,8 @@ public void RegisterLoggingEndpoint(Uri logEndpoint)
{
container.Configure(c =>
{
- c.For<MessageLoggingModule>().Singleton().Use<MessageLoggingModule>()
- .Ctor<Uri>().Is(logEndpoint);
+ c.For<IMessageModule>().Singleton()
+ .Use(ctx => new MessageLoggingModule(ctx.GetInstance<IEndpointRouter>(), logEndpoint));
c.For<IDeploymentAction>().Use<CreateLogQueueAction>();
});
}
View
4 Rhino.ServiceBus.Tests/Containers/StructureMap/Can_host_in_another_app_domain.cs
@@ -69,6 +69,10 @@ public void Consume(StringMsg message)
[CLSCompliant(false)]
public class SimpleBootStrapper : StructureMapBootStrapper
{
+ public SimpleBootStrapper()
+ {
+ }
+
public SimpleBootStrapper(IContainer container) : base(container)
{
}
View
25 Rhino.ServiceBus.Tests/Containers/StructureMap/ContainerTests.cs
@@ -1,6 +1,8 @@
using System;
-using System.Linq;
-using Rhino.ServiceBus.Exceptions;
+using System.Linq;
+using System.Reflection;
+using Rhino.ServiceBus.Exceptions;
+using Rhino.ServiceBus.Hosting;
using Rhino.ServiceBus.Impl;
using Rhino.ServiceBus.Internal;
using Rhino.ServiceBus.LoadBalancer;
@@ -34,6 +36,17 @@ public void Consumer_must_be_transient()
}
[Fact]
+ public void Can_register_log_endpoint()
+ {
+ var host = new DefaultHost();
+ host.BusConfiguration(x => x.Bus("rhino.queues://localhost/test_queue", "test_queue")
+ .AddAssembly(typeof (ServiceBus.RhinoQueues.RhinoQueuesTransport).Assembly)
+ .Receive("Rhino", "rhino.queues://localhost/test_queue")
+ .Logging("rhino.queues://localhost/log_queue"));
+ host.Start<SimpleBootStrapper>();
+ }
+
+ [Fact]
public void Bus_instance_is_singleton()
{
var container = ObjectFactory.Container;
@@ -95,7 +108,7 @@ public void Registers_logging_module()
.UseStandaloneConfigurationFile("BusWithLogging.config")
.Configure();
- var loggingModule = container.GetInstance<MessageLoggingModule>();
+ var loggingModule = container.GetAllInstances<IMessageModule>().OfType<MessageLoggingModule>().FirstOrDefault();
Assert.NotNull(loggingModule);
}
@@ -106,7 +119,7 @@ public void Registers_load_balancer_module()
new RhinoServiceBusConfiguration()
.UseStructureMap(container)
.UseStandaloneConfigurationFile("LoadBalancer/BusWithLoadBalancer.config")
- .Configure();
+ .Configure();
var loadBalancerMessageModule = container.GetInstance<LoadBalancerMessageModule>();
Assert.NotNull(loadBalancerMessageModule);
@@ -137,8 +150,8 @@ public void QueueCreationModule_can_be_resolved()
// var actions = container.GetAllInstances<IDeploymentAction>().ToList();
// Assert.True(actions.Count >= 2);
//}
- }
-
+ }
+
public class TestConsumer : ConsumerOf<string>
{
public void Consume(string message)
View
2 Rhino.ServiceBus/Config/LoggingConfigurationAware.cs
@@ -1,7 +1,6 @@
using System;
using System.Configuration;
using Rhino.ServiceBus.Impl;
-using Rhino.ServiceBus.MessageModules;
using Rhino.ServiceBus.Internal;
namespace Rhino.ServiceBus.Config
@@ -24,7 +23,6 @@ public void Configure(AbstractRhinoServiceBusConfiguration config, IBusContainer
"Attribute 'logEndpoint' on 'bus' has an invalid value '" + uriString + "'");
builder.RegisterLoggingEndpoint(logEndpoint);
- config.InsertMessageModuleAtFirst<MessageLoggingModule>();
}
}
}

0 comments on commit dd9598f

Please sign in to comment.