Permalink
Browse files

Merge branch 'deployment' of https://github.com/jberezanski/rhino-esb

…into deploy

Conflicts:
	Rhino.ServiceBus.Spring/SpringBuilder.cs
	Rhino.ServiceBus.Unity/UnityBuilder.cs
	Rhino.ServiceBus/Rhino.ServiceBus.csproj
  • Loading branch information...
2 parents 31260e5 + d4390e9 commit f6bb793404630958e264eda7c4c209cd50005e49 @CoreyKaylor CoreyKaylor committed Sep 14, 2012
View
@@ -10,4 +10,7 @@ nuget/
_ReSharper.*/
AssemblyInfo.cs
*.user
-push.cmd
+push.cmd
+*.metaproj
+*.metaproj.tmp
+TestResults/
@@ -1,9 +1,12 @@
using System;
+using Common.Logging;
namespace Rhino.ServiceBus.Host.Actions
{
public class DebugAction : IAction
{
+ private static readonly ILog Log = LogManager.GetCurrentClassLogger();
+
public void Execute(ExecutingOptions options)
{
var host = new RhinoServiceBusHost();
@@ -31,6 +34,7 @@ public void Execute(ExecutingOptions options)
}
catch (Exception e)
{
+ Log.Fatal("Host has crashed", e);
Console.WriteLine(e);
Console.ReadKey();
}
@@ -43,13 +43,15 @@ public static int Main(string[] args)
try
{
+ log.Debug("Executing action: " + action);
actions[action].Execute(executingOptions);
return 0;
}
catch (Exception e)
{
- log.Fatal("Host has crashed because of an error",e);
+ Console.WriteLine(e);
+ log.Fatal("Host has crashed because of an error", e);
// want to put the error in the error log
if(action == Action.Server)
throw;
@@ -1,7 +1,7 @@
-
-using System;
+using System;
using System.IO;
using System.Reflection;
+using Common.Logging;
namespace Rhino.ServiceBus.Host
{
@@ -10,6 +10,8 @@ namespace Rhino.ServiceBus.Host
internal partial class RhinoServiceBusHost : ServiceBase
{
+ private static readonly ILog Log = LogManager.GetCurrentClassLogger();
+
private RemoteAppDomainHost host;
private string asm;
private string cfg;
@@ -31,24 +33,32 @@ public void SetArguments(ExecutingOptions options)
protected override void OnStart(string[] ignored)
{
- if (string.IsNullOrEmpty(bootStrapper) == false)
- {
- var assembly = LoadAssembly();
- var bootStrapperType = LoadBootStrapperType(assembly);
- host = new RemoteAppDomainHost(bootStrapperType);
- host.Configuration(cfg);
- }
- else
+ try
{
- host = new RemoteAppDomainHost(asm, cfg);
- }
+ if (string.IsNullOrEmpty(bootStrapper) == false)
+ {
+ var assembly = LoadAssembly();
+ var bootStrapperType = LoadBootStrapperType(assembly);
+ host = new RemoteAppDomainHost(bootStrapperType);
+ host.Configuration(cfg);
+ }
+ else
+ {
+ host = new RemoteAppDomainHost(asm, cfg);
+ }
+
+ if (string.IsNullOrEmpty(hostType) == false)
+ {
+ host.SetHostType(hostType);
+ }
- if (string.IsNullOrEmpty(hostType) == false)
+ host.Start();
+ }
+ catch (Exception x)
{
- host.SetHostType(hostType);
+ Log.Fatal("Hosted service failed to start", x);
+ throw;
}
-
- host.Start();
}
private Assembly LoadAssembly()
@@ -77,8 +87,16 @@ private Type LoadBootStrapperType(Assembly assembly)
protected override void OnStop()
{
- if (host != null)
- host.Close();
+ try
+ {
+ if (host != null)
+ host.Close();
+ }
+ catch (Exception x)
+ {
+ Log.Fatal("Hosted service failed to stop", x);
+ throw;
+ }
}
public void DebugStart(string[] arguments)
@@ -136,7 +136,7 @@ public void RegisterLoadBalancerEndpoint(Uri loadBalancerEndpoint)
public void RegisterLoggingEndpoint(Uri logEndpoint)
{
applicationContext.RegisterSingleton(typeof(MessageLoggingModule).FullName, () => new MessageLoggingModule(applicationContext.Get<IEndpointRouter>(), logEndpoint));
- applicationContext.RegisterSingleton<IDeploymentAction>(() => new CreateLogQueueAction(applicationContext.Get<MessageLoggingModule>(), applicationContext.Get<ITransport>()));
+ applicationContext.RegisterSingleton<IDeploymentAction>(() => new CreateLogQueueAction(applicationContext.Get<IQueueStrategy>(), applicationContext.Get<MessageLoggingModule>(), applicationContext.Get<ITransport>()));
}
public void RegisterSingleton<T>(Func<T> func)
@@ -176,4 +176,4 @@ public void RegisterNoSecurity()
applicationContext.RegisterSingleton<IElementSerializationBehavior>(() => new ThrowingWireEncryptedMessageConvertor());
}
}
-}
+}
@@ -159,6 +159,7 @@ public void RegisterLoggingEndpoint(Uri logEndpoint)
container.RegisterType<IDeploymentAction, CreateLogQueueAction>(Guid.NewGuid().ToString(),
new ContainerControlledLifetimeManager(),
new InjectionConstructor(
+ new ResolvedParameter<IQueueStrategy>(),
new ResolvedParameter<MessageLoggingModule>(typeof(MessageLoggingModule).FullName),
new ResolvedParameter<ITransport>()));
}
@@ -209,4 +210,4 @@ public void RegisterNoSecurity()
new ContainerControlledLifetimeManager());
}
}
-}
+}
@@ -0,0 +1,45 @@
+using System.Messaging;
+using Rhino.ServiceBus.Msmq;
+
+namespace Rhino.ServiceBus.Actions
+{
+ public abstract class AbstractCreateQueuesAction : IDeploymentAction
+ {
+ private readonly IQueueStrategy queueStrategy;
+
+ protected AbstractCreateQueuesAction(IQueueStrategy queueStrategy)
+ {
+ this.queueStrategy = queueStrategy;
+ }
+
+ public abstract void Execute(string user);
+
+ protected void CreateQueues(QueueType mainQueueType, Endpoint mainQueueEndpoint, string user)
+ {
+ // will create the queues if they are not already there
+ var queues = queueStrategy.InitializeQueue(mainQueueEndpoint, mainQueueType);
+ foreach (var queue in queues)
+ {
+ GrantPermissions(queue, user);
+ }
+ }
+
+ protected void GrantPermissions(MessageQueue queue, string user)
+ {
+ if (!string.IsNullOrEmpty(user))
+ {
+ queue.SetPermissions(user,
+ MessageQueueAccessRights.DeleteMessage |
+ MessageQueueAccessRights.DeleteJournalMessage |
+ MessageQueueAccessRights.GenericRead |
+ MessageQueueAccessRights.GenericWrite |
+ MessageQueueAccessRights.GetQueuePermissions |
+ MessageQueueAccessRights.PeekMessage |
+ MessageQueueAccessRights.ReceiveJournalMessage |
+ MessageQueueAccessRights.ReceiveMessage |
+ MessageQueueAccessRights.WriteMessage,
+ AccessControlEntryType.Allow);
+ }
+ }
+ }
+}
@@ -1,39 +1,21 @@
-using System;
-using System.Messaging;
using Rhino.ServiceBus.LoadBalancer;
using Rhino.ServiceBus.Msmq;
namespace Rhino.ServiceBus.Actions
{
- public class CreateLoadBalancerQueuesAction : IDeploymentAction
+ public class CreateLoadBalancerQueuesAction : AbstractCreateQueuesAction
{
- private IQueueStrategy queueStrategy;
- private MsmqLoadBalancer loadBalancer;
+ private readonly MsmqLoadBalancer loadBalancer;
public CreateLoadBalancerQueuesAction(IQueueStrategy queueStrategy, MsmqLoadBalancer loadBalancer)
+ : base(queueStrategy)
{
- this.queueStrategy = queueStrategy;
this.loadBalancer = loadBalancer;
}
- public void Execute(string user)
+ public override void Execute(string user)
{
- // will create the queues if they are not already there
- var queues = queueStrategy.InitializeQueue(loadBalancer.Endpoint, QueueType.LoadBalancer);
- foreach (var queue in queues)
- {
- queue.SetPermissions(user,
- MessageQueueAccessRights.DeleteMessage |
- MessageQueueAccessRights.DeleteJournalMessage |
- MessageQueueAccessRights.GenericRead |
- MessageQueueAccessRights.GenericWrite |
- MessageQueueAccessRights.GetQueuePermissions |
- MessageQueueAccessRights.PeekMessage |
- MessageQueueAccessRights.ReceiveJournalMessage |
- MessageQueueAccessRights.ReceiveMessage |
- MessageQueueAccessRights.WriteMessage,
- AccessControlEntryType.Allow);
- }
+ this.CreateQueues(QueueType.LoadBalancer, loadBalancer.Endpoint, user);
}
}
}
@@ -1,23 +1,23 @@
-using System;
using System.Messaging;
using Rhino.ServiceBus.Internal;
using Rhino.ServiceBus.MessageModules;
using Rhino.ServiceBus.Msmq;
namespace Rhino.ServiceBus.Actions
{
- public class CreateLogQueueAction : IDeploymentAction
+ public class CreateLogQueueAction : AbstractCreateQueuesAction
{
private readonly MessageLoggingModule messageLoggingModule;
private readonly ITransport transport;
- public CreateLogQueueAction(MessageLoggingModule messageLoggingModule, ITransport transport)
+ public CreateLogQueueAction(IQueueStrategy queueStrategy, MessageLoggingModule messageLoggingModule, ITransport transport)
+ : base(queueStrategy)
{
this.messageLoggingModule = messageLoggingModule;
this.transport = transport;
}
- public void Execute(string user)
+ public override void Execute(string user)
{
// will create the queues if they are not already there
messageLoggingModule.Init(transport, null);
@@ -28,17 +28,7 @@ public void Execute(string user)
using (var queue = new MessageQueue(queuePath))
{
- queue.SetPermissions(user,
- MessageQueueAccessRights.DeleteMessage |
- MessageQueueAccessRights.DeleteJournalMessage |
- MessageQueueAccessRights.GenericRead |
- MessageQueueAccessRights.GenericWrite |
- MessageQueueAccessRights.GetQueuePermissions |
- MessageQueueAccessRights.PeekMessage |
- MessageQueueAccessRights.ReceiveJournalMessage |
- MessageQueueAccessRights.ReceiveMessage |
- MessageQueueAccessRights.WriteMessage,
- AccessControlEntryType.Allow);
+ GrantPermissions(queue, user);
}
}
}
@@ -1,38 +1,20 @@
-using System;
-using System.Messaging;
using Rhino.ServiceBus.Msmq;
namespace Rhino.ServiceBus.Actions
{
- public class CreateQueuesAction : IDeploymentAction
+ public class CreateQueuesAction : AbstractCreateQueuesAction
{
- private readonly IQueueStrategy queueStrategy;
private readonly IServiceBus serviceBus;
public CreateQueuesAction(IQueueStrategy queueStrategy, IServiceBus serviceBus)
+ : base(queueStrategy)
{
- this.queueStrategy = queueStrategy;
this.serviceBus = serviceBus;
}
- public void Execute(string user)
+ public override void Execute(string user)
{
- // will create the queues if they are not already there
- var queues = queueStrategy.InitializeQueue(serviceBus.Endpoint, QueueType.Standard);
- foreach (var queue in queues)
- {
- queue.SetPermissions(user,
- MessageQueueAccessRights.DeleteMessage |
- MessageQueueAccessRights.DeleteJournalMessage |
- MessageQueueAccessRights.GenericRead |
- MessageQueueAccessRights.GenericWrite |
- MessageQueueAccessRights.GetQueuePermissions |
- MessageQueueAccessRights.PeekMessage |
- MessageQueueAccessRights.ReceiveJournalMessage |
- MessageQueueAccessRights.ReceiveMessage |
- MessageQueueAccessRights.WriteMessage,
- AccessControlEntryType.Allow);
- }
+ this.CreateQueues(QueueType.Standard, serviceBus.Endpoint, user);
}
}
}
@@ -1,38 +1,21 @@
-using System.Messaging;
-using Rhino.ServiceBus.LoadBalancer;
+using Rhino.ServiceBus.LoadBalancer;
using Rhino.ServiceBus.Msmq;
namespace Rhino.ServiceBus.Actions
{
- public class CreateReadyForWorkQueuesAction: IDeploymentAction
+ public class CreateReadyForWorkQueuesAction : AbstractCreateQueuesAction
{
- private IQueueStrategy queueStrategy;
- private MsmqReadyForWorkListener readyForWorkListener;
+ private readonly MsmqReadyForWorkListener readyForWorkListener;
public CreateReadyForWorkQueuesAction(IQueueStrategy queueStrategy, MsmqReadyForWorkListener readyForWorkListener)
+ : base(queueStrategy)
{
- this.queueStrategy = queueStrategy;
this.readyForWorkListener = readyForWorkListener;
}
- public void Execute(string user)
+ public override void Execute(string user)
{
- // will create the queues if they are not already there
- var queues = queueStrategy.InitializeQueue(readyForWorkListener.Endpoint, QueueType.Raw);
- foreach (var queue in queues)
- {
- queue.SetPermissions(user,
- MessageQueueAccessRights.DeleteMessage |
- MessageQueueAccessRights.DeleteJournalMessage |
- MessageQueueAccessRights.GenericRead |
- MessageQueueAccessRights.GenericWrite |
- MessageQueueAccessRights.GetQueuePermissions |
- MessageQueueAccessRights.PeekMessage |
- MessageQueueAccessRights.ReceiveJournalMessage |
- MessageQueueAccessRights.ReceiveMessage |
- MessageQueueAccessRights.WriteMessage,
- AccessControlEntryType.Allow);
- }
+ this.CreateQueues(QueueType.Raw, readyForWorkListener.Endpoint, user);
}
}
}
Oops, something went wrong. Retry.

0 comments on commit f6bb793

Please sign in to comment.