Exemple #1
0
        public MessagingService(IOutbox outbox, IServiceFactory factory, Profile profile = null, MessagingConfiguration configuration = null)
        {
            ProcessId           = Process.GetCurrentProcess().Id;
            MachineName         = Environment.MachineName;
            MachineAndProcessId = $"{MachineName}-{ProcessId}";

            _configuration = configuration ?? new MessagingConfiguration();

            if (outbox == null)
            {
                throw new InvalidOperationException("Outbox cannot be null. An Outbo is required to instantiate MessagingService");
            }
            _outboxManager = new OutboxManager(outbox, this.DispatchCore, 1, _configuration.OutboxConsumerSemaphore, this.MachineAndProcessId);

            if (factory == null)
            {
                throw new InvalidOperationException("IServiceFactory cannot be null. An IServiceFactory is required to instantiate MessagingService");
            }
            _messageHandlerDispatcher = new MessageDispatcher(factory);

            if (profile != null)
            {
                _configure(profile);
            }

            _immediateHandleRetryPolicy = Policy
                                          .Handle <Exception>(x => !(x is NonTransientException))
                                          .RetryAsync(_maxImmediateRetryCount);
        }
 public UnitOfWorkManager(IUnitOfWorkFactory <TUnitOfWork> unitOfWorkFactory, IOutboxManager outboxManager)
 {
     _unitOfWorkFactory = unitOfWorkFactory;
     _outboxManager     = outboxManager;
 }