public TicketingApplication(ITicketCommandFactory ticketCommandFactory, IConcertService concertService, IApplicationServiceBus applicationServiceBus)
        {
            ApplicationServiceBus = applicationServiceBus;

            var inputBufferSize = 2 << 10;

            var claimStrategy = new SingleThreadedClaimStrategy(inputBufferSize);
            var waitStrategy = new SleepingWaitStrategy();
            var commandHandlers = new CommandHandlerCollection();
            RegisterCommandHandlers(concertService, commandHandlers);

            inputDisruptor = new Disruptor<CommandMessage>(() => new CommandMessage(), claimStrategy, waitStrategy, TaskScheduler.Default);
            inputDisruptor.HandleEventsWith(new CommandMessageHandler(commandHandlers));

            // Publishers and translators to input buffer
            commandMessageTranslator = new CommandMessageTranslator(ticketCommandFactory, ApplicationServiceBus);
        }
Exemple #2
0
 public BarService(IApplicationServiceBus serviceBus, ISomeBarClass someBarClass)
 {
     this.serviceBus   = serviceBus;
     this.someBarClass = someBarClass;
 }
Exemple #3
0
        public static void Init(
            IApplicationLog applicationLog,
            Func <ILogWriter, IApplicationWatchdog> initWatchdog,
            Func <ILogWriter, IExceptionHandler> initExceptionHandler,
            Func <ILogWriter, IAgentIdentity> initAgentIdentity,
            Func <ILogWriter, IAgentIdentity, ISettingsProvider> initSettingsProvider,
            Action <ISettingsProvider, IApplicationLog, IAgentIdentity> initApplicationLog,
            Func
            <IExceptionHandler, ILogWriter, ISettingsProvider, IAgentIdentity, IApplicationWatchdog,
             IApplicationServiceBus> loadServiceBus,
            Action onShutDown)
        {
            if (applicationLog == null)
            {
                throw new ArgumentNullException("applicationLog");
            }
            if (initWatchdog == null)
            {
                throw new ArgumentNullException("initWatchdog");
            }
            if (initApplicationLog == null)
            {
                throw new ArgumentNullException("initApplicationLog");
            }
            if (initExceptionHandler == null)
            {
                throw new ArgumentNullException("initExceptionHandler");
            }
            if (initSettingsProvider == null)
            {
                throw new ArgumentNullException("initSettingsProvider");
            }
            if (initAgentIdentity == null)
            {
                throw new ArgumentNullException("initAgentIdentity");
            }
            if (onShutDown == null)
            {
                throw new ArgumentNullException("onShutDown");
            }
            if (loadServiceBus == null)
            {
                throw new ArgumentNullException("loadServiceBus");
            }

            _onShutDown = onShutDown;

            IApplicationWatchdog watchdog = initWatchdog(applicationLog);

            watchdog.BeatDog();

            _exceptionHandler = initExceptionHandler(applicationLog);

            _agentIdentity = initAgentIdentity(applicationLog);

            applicationLog.AddEntry(
                new LogEntry(
                    MessageLevel.AppLifecycle,
                    ThisClassName,
                    string.Format("Agent {0} started.", _agentIdentity.ID)));

            _settingsProvider = initSettingsProvider(applicationLog, _agentIdentity);

            initApplicationLog(_settingsProvider, applicationLog, _agentIdentity);

            _applicationLog = applicationLog;

            _serviceBus = loadServiceBus(_exceptionHandler, applicationLog, _settingsProvider, _agentIdentity, watchdog);

            _settingsProvider.SettingsChanged += SettingsProvider_SettingsChanged;
        }