public IEndpointConfiguration Bootstrap(EndpointDefinition endpointDefinition)
    {
        if (endpointDefinition.MachineName != null)
        {
            RuntimeEnvironment.MachineNameAction = () => endpointDefinition.MachineName;
        }

        busConfiguration = new BusConfiguration();

        busConfiguration.Conventions()
        .DefiningMessagesAs(
            t => t.Namespace != null && t.Namespace.EndsWith(".Messages") && t != typeof(TestEvent));
        busConfiguration.Conventions().DefiningEventsAs(t => t == typeof(TestEvent));

        busConfiguration.EndpointName(endpointDefinition.Name);
        busConfiguration.UsePersistence <InMemoryPersistence>();
        busConfiguration.EnableInstallers();
        busConfiguration.UseTransport <SqlServerTransport>();

        customConfiguration = new CustomConfiguration();
        busConfiguration.CustomConfigurationSource(customConfiguration);

        messageStore        = new MessageStore();
        subscriptionStore   = new SubscriptionStore();
        callbackResultStore = new CallbackResultStore();

        busConfiguration.RegisterComponents(c => c.RegisterSingleton(messageStore));
        busConfiguration.RegisterComponents(c => c.RegisterSingleton(subscriptionStore));

        busConfiguration.Pipeline.Register <SubscriptionBehavior.Registration>();

        return(this);
    }
    public IEndpointConfiguration Bootstrap(EndpointDefinition endpointDefinition)
    {
        if (endpointDefinition.MachineName != null)
        {
            RuntimeEnvironment.MachineNameAction = () => endpointDefinition.MachineName;
        }

        endpointConfiguration = new EndpointConfiguration(endpointDefinition.Name);

        endpointConfiguration.Conventions().DefiningMessagesAs(t => t.Namespace != null && t.Namespace.EndsWith(".Messages") && t != typeof(TestEvent));
        endpointConfiguration.Conventions().DefiningEventsAs(t => t == typeof(TestEvent));

        endpointConfiguration.EnableInstallers();
        endpointConfiguration.UsePersistence <InMemoryPersistence>();

        endpointConfiguration.Recoverability().Immediate(i => i.NumberOfRetries(0));
        endpointConfiguration.Recoverability().Delayed(d => d.NumberOfRetries(0));

        endpointConfiguration.AuditProcessedMessagesTo("audit");

        messageStore        = new MessageStore();
        callbackResultStore = new CallbackResultStore();
        subscriptionStore   = new SubscriptionStore();

        endpointConfiguration.RegisterComponents(c => c.RegisterSingleton(messageStore));
        endpointConfiguration.RegisterComponents(c => c.RegisterSingleton(subscriptionStore));

        endpointConfiguration.Pipeline.Register <SubscriptionMonitoringBehavior.Registration>();

        return(this);
    }
    public void Start()
    {
        var configFile = AppConfigGenerator.Generate(connectionString, connectionStringsOverrides);

        //HINT: we need to generate custom app.config because v1 sqltransports does a direct read from ConfigurationManager
        using (AppConfig.Change(configFile.FullName))
        {
            configure.UseTransport <SqlServer>();

            startableBus = configure.UnicastBus().CreateBus();
            bus          = startableBus.Start(() => configure.ForInstallationOn <NServiceBus.Installation.Environments.Windows>().Install());

            messageStore        = (MessageStore)configure.Builder.Build(typeof(MessageStore));
            subscriptionStore   = new SubscriptionStore();
            callbackResultStore = new CallbackResultStore();

            configure.Builder.Build <MessageDrivenSubscriptionManager>().ClientSubscribed += (sender, args) => { subscriptionStore.Increment(); };
        }
    }