public void CorrectlyHandlesMultipleLogicalMessages()
        {
            var gotWhat = new Dictionary<string, ManualResetEvent>
            {
                {"a", new ManualResetEvent(false)},
                {"b", new ManualResetEvent(false)},
                {"c", new ManualResetEvent(false)},
            };

            _activator.Handle<OldSchoolMessage>(async message =>
            {
                gotWhat[message.KeyChar].Set();
            });

            var correlationId = Guid.NewGuid().ToString();
            var messageId = Guid.NewGuid().ToString();

            var headers = new Dictionary<string, string>
                {
                    {"rebus-return-address", _newEndpoint},
                    {"rebus-correlation-id", correlationId},
                    {"rebus-msg-id", messageId},
                    {"rebus-content-type", "text/json"},
                    {"rebus-encoding", "utf-7"}
                };

            var jsonBody = ValidLegacyRebusMessageWithMultipleLogicalMessages;

            using (var queue = new MessageQueue(MsmqUtil.GetFullPath(_newEndpoint)))
            {
                queue.SendLegacyRebusMessage(jsonBody, headers);
            }

            gotWhat.ForEach(kvp => kvp.Value.WaitOrDie(TimeSpan.FromSeconds(5),
                $"Did not get message with KeyChar = '{kvp.Key}'"));
        }
        public void CanReceiveOldFormat()
        {
            var gotIt = new ManualResetEvent(false);

            _activator.Handle<OldSchoolMessage>(async message =>
            {
                if (message.KeyChar == "g")
                {
                    gotIt.Set();
                }
            });

            var correlationId = Guid.NewGuid().ToString();
            var messageId = Guid.NewGuid().ToString();

            var headers = new Dictionary<string, string>
                {
                    {"rebus-return-address", _newEndpoint},
                    {"rebus-correlation-id", correlationId},
                    {"rebus-msg-id", messageId},
                    {"rebus-content-type", "text/json"},
                    {"rebus-encoding", "utf-7"}
                };

            var jsonBody = ValidLegacyRebusMessage;

            using (var queue = new MessageQueue(MsmqUtil.GetFullPath(_newEndpoint)))
            {
                queue.SendLegacyRebusMessage(jsonBody, headers);
            }

            gotIt.WaitOrDie(TimeSpan.FromSeconds(5));
        }
Exemple #3
0
        public async Task CanHandleSubscriptionRequest()
        {
            var messageId = Guid.NewGuid().ToString();
            var headers = new Dictionary<string, string>
                {
                    {"rebus-return-address", _oldEndpoint},
                    {"rebus-msg-id", messageId},
                    {"rebus-content-type", "text/json"},
                    {"rebus-encoding", "utf-7"}
                };

            using (var queue = new MessageQueue(MsmqUtil.GetFullPath(_newEndpoint)))
            {
                queue.SendLegacyRebusMessage(SubscriptionRequest, headers);
            }

            await Task.Delay(1000);

            var topic = "NewEndpoint.Messages.NewRequest, NewEndpoint.Messages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";

            Assert.That(_subscriptions.Count, Is.EqualTo(1));
            Assert.That(_subscriptions[topic].Count, Is.EqualTo(1));
            Assert.That(_subscriptions[topic].First(), Is.EqualTo(_oldEndpoint));
        }