Skip to content

Commit

Permalink
THe lite profile is now setting the default to inmemory gateway persi…
Browse files Browse the repository at this point in the history
…stence

instead of forcing it
  • Loading branch information
andreasohlund committed Jan 4, 2012
1 parent 54c3fdf commit afec46f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 27 deletions.
16 changes: 16 additions & 0 deletions src/gateway/NServiceBus.Gateway/Config/ConfigureGateway.cs
Expand Up @@ -12,6 +12,7 @@ namespace NServiceBus
using Gateway.Routing.Endpoints;
using Gateway.Routing.Sites;
using Gateway.Sending;
using Raven.Client;

public static class ConfigureGateway
{
Expand Down Expand Up @@ -52,13 +53,28 @@ public static Configure UseInMemoryGatewayPersister(this Configure config)
config.Configurer.ConfigureComponent<InMemoryPersistence>(DependencyLifecycle.SingleInstance);
return config;
}

/// <summary>
/// Sets the default persistence to inmemory
/// </summary>
/// <param name="config"></param>
/// <returns></returns>
public static Configure DefaultToInMemoryGatewayPerstence(this Configure config)
{
GatewayDefaults.DefaultPersistence = () => UseInMemoryGatewayPersister(config);

return config;
}
/// <summary>
/// Use RavenDB messages persistence by the gateway.
/// </summary>
/// <param name="config"></param>
/// <returns></returns>
public static Configure UseRavenGatewayPersister(this Configure config)
{
if (!config.Configurer.HasComponent<IDocumentStore>())
config.RavenPersistence();

config.Configurer.ConfigureComponent<RavenDbPersistence>(DependencyLifecycle.SingleInstance);
return config;
}
Expand Down
30 changes: 11 additions & 19 deletions src/gateway/NServiceBus.Gateway/Config/GatewayDefaults.cs
@@ -1,28 +1,20 @@

namespace NServiceBus
namespace NServiceBus.Gateway.Config
{
using ObjectBuilder;
using Config;
using Gateway.Persistence;
using Gateway.Persistence.Raven;
using Gateway.Sending;
using Raven.Client;
using System;
using NServiceBus.Config;
using Persistence;
using Sending;

class GatewayDefaults : IWantToRunWhenConfigurationIsComplete
public class GatewayDefaults : IWantToRunWhenConfigurationIsComplete
{
public IConfigureComponents Configurer { get; set; }
public static Action DefaultPersistence = () => Configure.Instance.UseRavenGatewayPersister();

public void Run()
{
if (!Configurer.HasComponent<GatewaySender>())
if (!Configure.Instance.Configurer.HasComponent<GatewaySender>() || Configure.Instance.Configurer.HasComponent<IPersistMessages>())
return;

if (!Configurer.HasComponent<IPersistMessages>())
{
if (!Configurer.HasComponent<IDocumentStore>())
Configure.Instance.RavenPersistence();
Configurer.ConfigureComponent<RavenDbPersistence>(DependencyLifecycle.InstancePerCall);
}


DefaultPersistence();
}
}
}
Expand Up @@ -10,16 +10,13 @@
namespace NServiceBus.Hosting.Windows.Profiles.Handlers
{

internal class LiteProfileHandler : IHandleProfile<Lite>, IWantTheEndpointConfig, IWantTheListOfActiveProfiles
internal class LiteProfileHandler : IHandleProfile<Lite>, IWantTheEndpointConfig
{
void IHandleProfile.ProfileActivated()
{
Configure.Instance.DefaultToInMemoryTimeoutPersistence();

if (ActiveProfiles.Contains(typeof(RunGateway)))
Configure.Instance.UseInMemoryGatewayPersister();

Configure.Instance.AsMasterNode();
Configure.Instance.AsMasterNode()
.DefaultToInMemoryTimeoutPersistence()
.DefaultToInMemoryGatewayPerstence();

if (!Configure.Instance.Configurer.HasComponent<ISagaPersister>())
Configure.Instance.InMemorySagaPersister();
Expand All @@ -35,6 +32,5 @@ void IHandleProfile.ProfileActivated()
}

public IConfigureThisEndpoint Config { get; set; }
public IEnumerable<Type> ActiveProfiles { get; set; }
}
}

0 comments on commit afec46f

Please sign in to comment.