Esempio n. 1
0
        private void Initialize(Action <IServiceBusConfigurator> busConfigureAction)
        {
            _publishSettings.Validate();

            if (_publishSettings.UsePublisherConfirms)
            {
                Action <IServiceBusConfigurator> publisherConfirmConfigureAction =
                    configurator =>
                {
                    busConfigureAction(configurator);
                    configurator.UsePublisherConfirms(_publishSettings);
                };
                _serviceBus = ServiceBusFactory.New(publisherConfirmConfigureAction);
            }
            else
            {
                _serviceBus = ServiceBusFactory.New(busConfigureAction);
            }

            _confirmer         = _publishSettings.Confirmer;
            _messageRepository = UnconfirmedMessageRepositoryFactory.Create(_publishSettings);

            _confirmer.PublicationFailed    += OnPublicationFailed;
            _confirmer.PublicationSucceeded += OnPublicationSucceeded;

            _lastMessageBufferStoreTimestamp = DateTime.UtcNow.Ticks;
            _lastPublishRetryTimestamp       = DateTime.UtcNow.Ticks;
            _checkOfflineTasksTimer          = new Timer(CheckOfflineTasks, null, _publishSettings.TimerCheckInterval, _publishSettings.TimerCheckInterval);
        }
Esempio n. 2
0
        public Publisher(Action <IServiceBusConfigurator> busConfigureAction, Action <PublishSettings> publishConfigureAction = null)
        {
            _publishSettings = new PublishSettings();
            if (publishConfigureAction != null)
            {
                publishConfigureAction(_publishSettings);
            }

            _publishSettings.Validate();

            Initialize(busConfigureAction);
        }