CreateQueue() public static method

public static CreateQueue ( string path ) : void
path string
return void
Ejemplo n.º 1
0
        public void Should_set_label_when_convention_configured()
        {
            var queueName = "labelTest";
            var path      = $@"{RuntimeEnvironment.MachineName}\private$\{queueName}";

            try
            {
                MsmqHelpers.DeleteQueue(path);
                MsmqHelpers.CreateQueue(path);
                var messageSender = new MsmqMessageDispatcher(new MsmqSettings(), _ => "mylabel");

                var bytes = new byte[]
                {
                    1
                };
                var headers            = new Dictionary <string, string>();
                var outgoingMessage    = new OutgoingMessage("1", headers, bytes);
                var transportOperation = new TransportOperation(outgoingMessage, new UnicastAddressTag(queueName), DispatchConsistency.Default);
                messageSender.Dispatch(new TransportOperations(transportOperation), new TransportTransaction(), new ContextBag());
                var messageLabel = ReadMessageLabel(path);
                Assert.AreEqual("mylabel", messageLabel);
            }
            finally
            {
                MsmqHelpers.DeleteQueue(path);
            }
        }
Ejemplo n.º 2
0
        public void Should_use_string_empty_label_when_no_convention_configured()
        {
            var queueName = "emptyLabelTest";
            var path      = $@".\private$\{queueName}";

            try
            {
                MsmqHelpers.DeleteQueue(path);
                MsmqHelpers.CreateQueue(path);
                var messageSender = new MsmqMessageDispatcher(new MsmqSettings(), pairs => string.Empty);

                var bytes = new byte[]
                {
                    1
                };
                var headers            = new Dictionary <string, string>();
                var outgoingMessage    = new OutgoingMessage("1", headers, bytes);
                var transportOperation = new TransportOperation(outgoingMessage, new UnicastAddressTag(queueName), DispatchConsistency.Default);
                messageSender.Dispatch(new TransportOperations(transportOperation), new TransportTransaction(), new ContextBag());
                var messageLabel = ReadMessageLabel(path);
                Assert.IsEmpty(messageLabel);
            }
            finally
            {
                MsmqHelpers.DeleteQueue(path);
            }
        }
Ejemplo n.º 3
0
        public void Setup()
        {
            var queueName = "permissionsTest";

            path = $@"{RuntimeEnvironment.MachineName}\private$\{queueName}";
            MsmqHelpers.DeleteQueue(path);
            MsmqHelpers.CreateQueue(path);

            queue = new MessageQueue(path);
        }
        static Message DispatchMessage(string queueName, MsmqSettings settings = null, DeliveryConstraint deliveryConstraint = null, Func <IReadOnlyDictionary <string, string>, string> messageLabelGenerator = null)
        {
            if (settings == null)
            {
                settings = new MsmqSettings();
            }

            if (messageLabelGenerator == null)
            {
                messageLabelGenerator = _ => string.Empty;
            }

            var path = $@".\private$\{queueName}";

            try
            {
                MsmqHelpers.DeleteQueue(path);
                MsmqHelpers.CreateQueue(path);

                var messageSender = new MsmqMessageDispatcher(settings, messageLabelGenerator);

                var bytes = new byte[]
                {
                    1
                };
                var headers             = new Dictionary <string, string>();
                var outgoingMessage     = new OutgoingMessage("1", headers, bytes);
                var deliveryConstraints = new List <DeliveryConstraint>();

                if (deliveryConstraint != null)
                {
                    deliveryConstraints.Add(deliveryConstraint);
                }

                var transportOperation = new TransportOperation(outgoingMessage, new UnicastAddressTag(queueName), DispatchConsistency.Default, deliveryConstraints);

                messageSender.Dispatch(new TransportOperations(transportOperation), new TransportTransaction(), new ContextBag());

                using (var queue = new MessageQueue(path))
                    using (var message = queue.Receive(TimeSpan.FromSeconds(5)))
                    {
                        return(message);
                    }
            }
            finally
            {
                MsmqHelpers.DeleteQueue(path);
            }
        }