Пример #1
0
 public ToolConsumer(IProcessor <Tool> processor, IQueueConnection queueConnection,
                     IGenericRepository <Mongo.Dto.Tool> toolGenericRepository)
 {
     _processor             = processor;
     _queueConnection       = queueConnection;
     _toolGenericRepository = toolGenericRepository;
 }
Пример #2
0
 public StateConsumer(IProcessor <State> processor, IQueueConnection queueConnection,
                      IGenericRepository <Mongo.Dto.State> stateGenericRepository)
 {
     _processor              = processor;
     _queueConnection        = queueConnection;
     _stateGenericRepository = stateGenericRepository;
 }
        public IdentityController(IServiceProvider provider)
        {
            var bl = new BusinessManager();

            user             = bl.GetUser();
            _queueConnection = provider.GetRequiredService <RabbitMQQueueConnection>();
        }
Пример #4
0
 public MessageConsumer(IProcessor <Message> processor,
                        IQueueConnection queueConnection,
                        IGenericRepository <Mongo.Dto.Message> messageGenericRepository)
 {
     _processor                = processor;
     _queueConnection          = queueConnection;
     _messageGenericRepository = messageGenericRepository;
 }
        public QueueConnectionWorker(IQueueConnection queueConnection, string queueName)
        {
            _queueConnection = queueConnection;
            _queueName       = queueName;
            var bl = new BusinessManager();

            _responseHandler = bl.GetResponseActions();
        }
        /// <summary>
        /// Scale Unit
        /// </summary>
        /// <param name="queue">Queue Setup</param>
        /// <returns>Scalable Task</returns>
        public override IEnumerable <IScalable> ScaleUnit(IQueueConnection <T> queue)
        {
            if (null == queue)
            {
                throw new ArgumentNullException("queue");
            }

            yield return(this.throughput.Runner(this.Runs(queue), queue.Setup.Priority));
        }
Пример #7
0
 public HistoryJobPieceBarConsumer(
     IProcessor <HistoryJobPieceBar> processor,
     IQueueConnection queueConnection,
     IGenericRepository <Mongo.Dto.HistoryJobPieceBar> messageGenericRepository)
 {
     _processor                = processor;
     _queueConnection          = queueConnection;
     _messageGenericRepository = messageGenericRepository;
 }
        /// <summary>
        /// Mockable Constructor
        /// </summary>
        /// <param name="count">Count</param>
        /// <param name="connection">Connection</param>
        /// <param name="throughput">Throughput</param>
        /// <param name="messagesPerScaleUnit">Messages Per-Scale Unit</param>
        /// <param name="connection">Setup</param>
        /// <param name="minimum">Minimum Scale</param>
        /// <param name="maximum">Maximmum Scale</param>
        /// <param name="checkScaleInMinutes">Check Scale Every</param>
        public StorageQueueAutoScaler(IQueueCount count, IQueueConnection <T> connection, IQueueThroughput throughput, ushort messagesPerScaleUnit = QueueScaler <T> .MessagesPerScaleUnitDefault, byte minimum = 1, byte maximum = 2, byte checkScaleInMinutes = BaseTimes.ScaleCheck)
            : base(count, messagesPerScaleUnit, connection, minimum, maximum, checkScaleInMinutes)
        {
            if (null == throughput)
            {
                throw new ArgumentNullException("throughput");
            }

            this.throughput = throughput;
        }
        /// <summary>
        /// Runs
        /// </summary>
        /// <param name="queue">Queue Setup</param>
        /// <returns>Dynamic Runs</returns>
        public virtual IDynamicRuns Runs(IQueueConnection <T> queue)
        {
            if (null == queue)
            {
                throw new ArgumentNullException("setup");
            }

            var frequency = this.throughput.Frequency(queue.Setup.Priority);

            return(new StorageDequeueBatchDynamic <T>(queue.Setup.Name, queue.ConnectionString, queue.Setup.Processor(), frequency.Minimum, frequency.Maximum));
        }
Пример #10
0
        private void Init()
        {
            var builder = new ContainerBuilder();

            Ioc.IocContainerBuilder.BuildCore(builder, false, true);

            CurrentContainer = builder.Build();
            Connection       = CurrentContainer.Resolve <IQueueConnection>();
            _scopeVariable   = CurrentContainer.BeginLifetimeScope();
            _scopeInfo       = CurrentContainer.BeginLifetimeScope();
            _scopeMessage    = CurrentContainer.BeginLifetimeScope();
            _scopeHistoryJob = CurrentContainer.BeginLifetimeScope();
            _scopeTool       = CurrentContainer.BeginLifetimeScope();
            _scopeState      = CurrentContainer.BeginLifetimeScope();
            _scopeUnknown    = CurrentContainer.BeginLifetimeScope();

            var consumerVariable = _scopeVariable.Resolve <IConsumer <VariablesList> >();

            consumerVariable.Log += WriteLog;
            consumerVariable.Init();

            var consumerInfo = _scopeInfo.Resolve <IConsumer <Info> >();

            consumerInfo.Log += WriteLog;
            consumerInfo.Init();

            var consumerState = _scopeState.Resolve <IConsumer <State> >();

            consumerState.Log += WriteLog;
            consumerState.Init();

            var consumerHistoryJob = _scopeHistoryJob.Resolve <IConsumer <HistoryJobPieceBar> >();

            consumerHistoryJob.Log += WriteLog;
            consumerHistoryJob.Init();

            var consumerMessage = _scopeMessage.Resolve <IConsumer <Message> >();

            consumerMessage.Log += WriteLog;
            consumerMessage.Init();


            var consumerTool = _scopeTool.Resolve <IConsumer <Tool> >();

            consumerTool.Log += WriteLog;
            consumerTool.Init();
        }
Пример #11
0
        public void Test()
        {
            _subscription = _queueConnection.Open(c => c.OpenTimeout(TimeSpan.FromSeconds(1)).PrefetchCount(5).ArgList(null));

            Task.Factory.StartNew(() =>
            {
                var observable = _subscription.Stream <MyMessage>();
                observable.Count().Subscribe(i => { Console.WriteLine("Count changed"); });

                using (observable
                       .SubscribeWithAck(rm =>
                {
                    Console.WriteLine("Recieved message: " + rm.Message.Greeting);
                    Console.WriteLine(observable.Count());
                }));
            });

            Task.Delay(TimeSpan.FromSeconds(5)).Wait();
        }
Пример #12
0
        public void Consume(IQueueConnection queueConnection)
        {
            using (var model = queueConnection.Connection.CreateModel()) {
                var consumer = new EventingBasicConsumer(model);
                model.BasicQos(prefetchSize: 0, prefetchCount: 1, global: false);

                consumer.Received += async(receivedModel, ea) => {
                    var user = userConverter.GetUser(ea.Body);
                    if (user != null)
                    {
                        await this.consumer.ConsumeAsync(user);
                    }

                    model.BasicAck(deliveryTag: ea.DeliveryTag, multiple: false);
                };

                model.BasicConsume(queue: Consts.StatusQueue, autoAck: false, consumer: consumer);

                while (true)
                {
                }
            }
        }
Пример #13
0
 public MessageProducer(IQueueConnection queueConnection)
 {
     _queueConnection = queueConnection;
 }
Пример #14
0
 public InfoProducer(IQueueConnection queueConnection)
 {
     _queueConnection = queueConnection;
 }
Пример #15
0
 public InfoConsumer(IProcessor <Info> processor,
                     IQueueConnection queueConnection)
 {
     _processor       = processor;
     _queueConnection = queueConnection;
 }
Пример #16
0
 public VariableListProducer(IQueueConnection queueConnection)
 {
     _queueConnection = queueConnection;
 }
 private static void TryCreateQueue(IQueueConnection connection, string queueName, bool isPersisted, bool isTransactional)
 {
     try
     {
         connection.Create(queueName, isPersisted, isTransactional);
     }
     catch (QueueException ex)
     {
         if (ex.ErrorInfo.ErrorCode != QueueErrorCode.QueueAlreadyExists) throw;
     }
 }
Пример #18
0
 public StateProducer(IQueueConnection queueConnection)
 {
     _queueConnection = queueConnection;
 }
Пример #19
0
 public Sender(IQueueConnection queueConnection)
 {
     this.queueConnection = queueConnection;
 }
 public QueueHandlerWorker(IQueueConnection connection, string queueName)
 {
     _queueConnection = connection;
     _queueName       = queueName;
     _adminBL         = new BusinessManager().GetAdminActions();
 }
Пример #21
0
 public RabbitMqClientService(IQueueConnection queueConnection, ISerializerService serializerService)
 {
     _queueConnection   = queueConnection;
     _serializerService = serializerService;
 }
 public RabbitMqQueueManagerService(IQueueConnection queueConnection)
 {
     _queueConnection = queueConnection;
 }
Пример #23
0
 public EndToEndRunner(string hostName, 
     int port, 
     string baseAddress, 
     string catalogLocation, 
     string persistLocation, 
     string transitLocation, 
     int transitCleanupInterval, 
     int transitMaximumAge, 
     string[] queueNames, 
     int senderCount, 
     int senderDelay, 
     int receiverCount, 
     int receiverDelay,
     bool isPersisted,
     bool isTransactional)
 {
     this.hostName = hostName;
     this.port = port;
     this.baseAddress = baseAddress;
     this.catalogLocation = catalogLocation;
     this.persistLocation = persistLocation;
     this.transitLocation = transitLocation;
     this.transitCleanupInterval = transitCleanupInterval;
     this.transitMaximumAge = transitMaximumAge;
     this.queueNames = queueNames;
     this.senderCount = senderCount;
     this.senderDelay = senderDelay;
     this.receiverCount = receiverCount;
     this.receiverDelay = receiverDelay;
     this.isPersisted = isPersisted;
     this.isTransactional = isTransactional;
     this.connection = MessageQueue.Connect(hostName, port, baseAddress);
     this.ReceiveExceptions = new List<QueueException>();
     this.SendExceptions = new List<QueueException>();
     this.SentMessage1List = new Dictionary<string, IEnumerable<TestMessage1>>();
     this.SentMessage2List = new Dictionary<string, IEnumerable<TestMessage2>>();
     this.ReceivedMessage1List = new Dictionary<string, IEnumerable<TestMessage1>>();
     this.ReceivedMessage2List = new Dictionary<string, IEnumerable<TestMessage2>>();
 }
Пример #24
0
 public ToolProducer(IQueueConnection queueConnection)
 {
     _queueConnection = queueConnection;
 }
 /// <summary>
 /// Default Constructor
 /// </summary>
 /// <param name="count">Count</param>
 /// <param name="messagesPerScaleUnit">Messages Per-Scale Unit</param>
 /// <param name="connection">Queue Connection</param>
 /// <param name="minimum">Minimum Scale</param>
 /// <param name="maximum">Maximmum Scale</param>
 /// <param name="checkScaleInMinutes">Check Scale Every</param>
 public StorageQueueAutoScaler(IQueueCount count, IQueueConnection <T> connection, ushort messagesPerScaleUnit = QueueScaler <T> .MessagesPerScaleUnitDefault, byte minimum = 1, byte maximum = 2, byte checkScaleInMinutes = BaseTimes.ScaleCheck)
     : this(count, connection, new QueueThroughput(), messagesPerScaleUnit, minimum, maximum, checkScaleInMinutes)
 {
 }
 public HistoryJobPieceBarProducer(IQueueConnection queueConnection)
 {
     _queueConnection = queueConnection;
 }