Exemplo n.º 1
0
        static List <int> SendMessages(int messageCount)
        {
            var transport = new MsmqTransport(QueueName, new ConsoleLoggerFactory(true));

            MsmqUtil.EnsureQueueExists(MsmqUtil.GetPath(QueueName));

            var sendIds = new List <int>();

            Enumerable.Range(0, messageCount)
            .Select(id => new SomeMessage {
                Id = id
            })
            .ToList()
            .ForEach(msg =>
            {
                using (var scope = new RebusTransactionScope())
                {
                    transport.Send(QueueName, TransportMessageHelpers.FromString(JsonConvert.SerializeObject(msg)), scope.TransactionContext).Wait();

                    scope.Complete();

                    sendIds.Add(msg.Id);
                }
            });

            return(sendIds);
        }
Exemplo n.º 2
0
        protected override void SetUp()
        {
            _newEndpoint = TestConfig.QueueName("newendpoint");
            _oldEndpoint = TestConfig.QueueName("oldendpoint");

            MsmqUtil.EnsureQueueExists(MsmqUtil.GetPath(_newEndpoint));
            MsmqUtil.EnsureQueueExists(MsmqUtil.GetPath(_oldEndpoint));

            _activator = Using(new BuiltinHandlerActivator());

            _bus = Configure.With(_activator)
                   .Transport(t => t.UseMsmq(_newEndpoint))
                   .Options(o =>
            {
                o.EnableLegacyCompatibility();
                o.LogPipeline(true);
            })
                   .Start();
        }
Exemplo n.º 3
0
        public async Task CanGetCount()
        {
            var path = MsmqUtil.GetPath(QueueName);

            MsmqUtil.EnsureQueueExists(path);

            Console.WriteLine($"Checking {path}");

            var countBefore = MsmqUtil.GetCount(path);

            await SendMessageTo(QueueName);
            await SendMessageTo(QueueName);
            await SendMessageTo(QueueName);

            var countAfter = MsmqUtil.GetCount(path);

            Assert.That(countBefore, Is.EqualTo(0));
            Assert.That(countAfter, Is.EqualTo(3));
        }
Exemplo n.º 4
0
        protected override void SetUp()
        {
            _newEndpoint = TestConfig.GetName("newendpoint");
            _oldEndpoint = TestConfig.GetName("oldendpoint");

            MsmqUtil.EnsureQueueExists(MsmqUtil.GetPath(_newEndpoint));
            MsmqUtil.EnsureQueueExists(MsmqUtil.GetPath(_oldEndpoint));

            _activator = Using(new BuiltinHandlerActivator());

            _subscriptions = new Dictionary <string, HashSet <string> >();

            _bus = Configure.With(_activator)
                   .Transport(t => t.UseMsmq(_newEndpoint))
                   .Subscriptions(s => s.Decorate(c => new SubDec(c.Get <ISubscriptionStorage>(), _subscriptions)))
                   .Routing(m => m.TypeBased().Map <string>(_oldEndpoint))
                   .Options(o =>
            {
                o.EnableLegacyCompatibility();
                o.LogPipeline();
            })
                   .Start();
        }