Exemple #1
0
        public void Run(StopWatch stopWatch)
        {
            _bus.Subscribe <GeneralMessage>(Handle);
            _bus.Subscribe <SimpleResponse>(Handler);

            stopWatch.Start();

            CheckPoint publishCheckpoint = stopWatch.Mark("Publishing " + _repeatCount + " messages");
            CheckPoint receiveCheckpoint = stopWatch.Mark("Receiving " + _repeatCount + " messages");

            for (int index = 0; index < _repeatCount; index++)
            {
                _bus.Publish(new GeneralMessage());
            }

            publishCheckpoint.Complete(_repeatCount);

            bool completed = _completeEvent.WaitOne(TimeSpan.FromSeconds(60), true);

            bool responseCompleted = _responseEvent.WaitOne(TimeSpan.FromSeconds(60), true);

            receiveCheckpoint.Complete(_counter + _responseCounter);

            stopWatch.Stop();
        }
        public void Run(StopWatch stopWatch)
        {
            stopWatch.Start();

            CheckPoint point         = stopWatch.Mark("Correlated Requests");
            CheckPoint responsePoint = stopWatch.Mark("Correlated Responses");

            var pool = new ManagedThreadPool <CorrelatedController>(DoWorker, 10, 10);

            try
            {
                for (int index = 0; index < _attempts; index++)
                {
                    var controller = new CorrelatedController(_bus, OnSuccess, OnTimeout);
                    pool.Enqueue(controller);
                }

                point.Complete(_attempts);

                _finishedEvent.WaitOne(TimeSpan.FromSeconds(60), true);

                responsePoint.Complete(_timeouts + _successes);
            }
            finally
            {
                pool.Dispose();
            }

            Console.WriteLine("Attempts: {0}, Succeeded: {1}, Timeouts: {2}", _attempts, _successes, _timeouts);

            stopWatch.Stop();
        }
Exemple #3
0
        public void Run(StopWatch stopWatch)
        {
            _container.AddComponent <RequestConsumer>();
            _container.AddComponent <ResponseConsumer>();

            _remoteBus.Subscribe <RequestConsumer>();
            _localBus.Subscribe <ResponseConsumer>();

            stopWatch.Start();

            CheckPoint publishCheckpoint = stopWatch.Mark("Publishing " + _repeatCount + " messages");
            CheckPoint receiveCheckpoint = stopWatch.Mark("Request/Response " + _repeatCount + " messages");

            for (int index = 0; index < _repeatCount; index++)
            {
                _localBus.Publish(new GeneralMessage());
            }

            publishCheckpoint.Complete(_repeatCount);

            _completeEvent.WaitOne(TimeSpan.FromSeconds(60), true);

            _responseEvent.WaitOne(TimeSpan.FromSeconds(60), true);

            receiveCheckpoint.Complete(_counter + _responseCounter);

            stopWatch.Stop();
        }
Exemple #4
0
        public void Run(StopWatch watch)
        {
            _container = new HeavyLoadContainer();

            _bus = _container.Resolve <IServiceBus>();

            var management = MsmqEndpointManagement.New(_bus.Endpoint.Address.Uri);

            management.Purge();

            watch.Start();

            //BatchServiceComponent component = new BatchServiceComponent();

            //_bus.Subscribe(component);

            _container.AddComponent <BatchServiceComponent>();

            _bus.Subscribe <BatchServiceComponent>();

            int batchCount = 100;

            CheckPoint publishCheckpoint = watch.Mark("Publishing " + batchCount + " batches");

            _threads = new ManagedThreadPool <int>(delegate(int batchLength) { SendBatch(batchLength); }, 10, 10);

            for (int i = 0; i < batchCount; i++)
            {
                _threads.Enqueue(100);
            }

            for (int i = 0; i < batchCount; i++)
            {
                bool received = BatchServiceComponent.Received.WaitOne(TimeSpan.FromSeconds(30), true);
                if (!received)
                {
                    _log.Error("Something went wrong, we never got a batch completed");
                    break;
                }
            }

            publishCheckpoint.Complete(batchCount * 100);

            watch.Stop();

            _log.Info("Test Complete");
        }
Exemple #5
0
        public void Run(StopWatch stopWatch)
        {
            stopWatch.Start();

            CheckPoint publishCheckpoint = stopWatch.Mark("Sending " + _repeatCount + " messages");
            CheckPoint receiveCheckpoint = stopWatch.Mark("Request/Response " + _repeatCount + " messages");

            for (int index = 0; index < _repeatCount; index++)
            {
                _bus.Publish(new GeneralMessage());
            }

            publishCheckpoint.Complete(_repeatCount);

            _completeEvent.WaitOne(TimeSpan.FromSeconds(60), true);

            _responseEvent.WaitOne(TimeSpan.FromSeconds(60), true);

            receiveCheckpoint.Complete(_requestCounter + _responseCounter);

            stopWatch.Stop();
        }
Exemple #6
0
        public void Run(StopWatch stopWatch)
        {
            stopWatch.Start();

            CheckPoint publishCheckpoint = stopWatch.Mark("Sending " + _repeatCount + " messages");
            CheckPoint receiveCheckpoint = stopWatch.Mark("Request/Response " + _repeatCount + " messages");

            for (int index = 0; index < _repeatCount; index++)
            {
                Guid transactionId = Guid.NewGuid();

                _bus.PublishRequest(new SimpleRequestMessage(transactionId), x =>
                {
                    Interlocked.Increment(ref _requestCounter);

                    x.Handle <SimpleResponseMessage>(message =>
                    {
                        Interlocked.Increment(ref _responseCounter);

                        if (_responseCounter == _repeatCount)
                        {
                            _clientComplete.Set();
                        }
                    });

                    x.HandleTimeout(10.Seconds(), () => { });
                });
            }

            publishCheckpoint.Complete(_repeatCount);

            _handlerComplete.WaitOne(TimeSpan.FromSeconds(60), true);

            _clientComplete.WaitOne(TimeSpan.FromSeconds(60), true);

            receiveCheckpoint.Complete(_requestCounter + _responseCounter);

            stopWatch.Stop();
        }