Beispiel #1
0
        private static IMessageQueue GetMessageQueue(string path)
        {
            QueueReference qRef = QueueReference.Parse(path);
            IMessageQueue  q    = MessagingProviderLocator
                                  .GetProvider()
                                  .GetMessageQueue(qRef);

            return(q);
        }
        public void Parse()
        {
            string[] s = @".\def\ghi".Split(new char[] { '\\' }, 3);
            Assert.AreEqual(3, s.Length, "Fail");
            Assert.AreEqual(".", s[0], "Fail");

            QueueReference qr0 = QueueReference.Parse(@"\\host\private$\myqueue");

            Assert.AreEqual("host", qr0.Host);
            Assert.AreEqual(true, qr0.IsPrivate);
            Assert.AreEqual(@"private$\myqueue", qr0.Queue);

            QueueReference qr1 = QueueReference.Parse(@"\\host\myqueue");

            Assert.AreEqual("host", qr1.Host);
            Assert.AreEqual(false, qr1.IsPrivate);
            Assert.AreEqual("myqueue", qr1.Queue);

            QueueReference qr2 = QueueReference.Parse("myqueue");

            Assert.AreEqual("localhost", qr2.Host);
            Assert.AreEqual(false, qr2.IsPrivate);
            Assert.AreEqual("myqueue", qr2.Queue);
        }
 public static bool Exists(string path)
 {
     return(Exists(QueueReference.Parse(path)));
 }
        public static void Delete(string path)
        {
            QueueReference qRef = QueueReference.Parse(path);

            MessagingProviderLocator.GetProvider().DeleteQueue(qRef);
        }
Beispiel #5
0
        public IMessage ReadMessage(QueueReference destination, BasicDeliverEventArgs result)
        {
            /*
             * if (destination == null)
             *      throw new ArgumentException ("destination must not be null");
             * if (result == null)
             *      throw new ArgumentException ("result must not be null");
             */
            MessageBase msg = new MessageBase();
            Stream      s   = new MemoryStream();

            s.Write(result.Body, 0, result.Body.Length);
            DateTime    arrivedTime   = DateTime.Now;
            IDictionary headers       = result.BasicProperties.Headers;
            long        senderVersion = (long)headers[SENDER_VERSION_KEY];
            string      sourceMachine = GetString(headers, SOURCE_MACHINE_KEY);
            DateTime    sentTime      = AmqpTimestampToDateTime(result.BasicProperties.Timestamp);
            string      transactionId = GetString(headers, TRANSACTION_ID_KEY);

            msg.SetDeliveryInfo(Acknowledgment.None,
                                arrivedTime,
                                new RabbitMQMessageQueue(provider,
                                                         destination,
                                                         true),
                                result.BasicProperties.MessageId,
                                MessageType.Normal,
                                new byte[0],
                                senderVersion,
                                sentTime,
                                sourceMachine,
                                transactionId);
            msg.CorrelationId   = result.BasicProperties.CorrelationId;
            msg.BodyStream      = s;
            msg.BodyType        = (int)result.BasicProperties.Headers[BODY_TYPE_KEY];
            msg.AcknowledgeType = (AcknowledgeTypes)
                                  Enum.ToObject(typeof(AcknowledgeTypes),
                                                headers[ACKNOWLEDGE_TYPE_KEY]);
            string adminQueuePath = GetString(headers, ADMINISTRATION_QUEUE_KEY);

            if (adminQueuePath != null)
            {
                QueueReference qRef = QueueReference.Parse(adminQueuePath);
                msg.AdministrationQueue = new RabbitMQMessageQueue(provider,
                                                                   qRef,
                                                                   true);
            }
            msg.AppSpecific = (int)headers[APP_SPECIFIC_KEY];
            msg.AuthenticationProviderName = GetString(headers, AUTHENTICATION_PROVIDER_NAME_KEY);
            msg.AuthenticationProviderType = (CryptographicProviderType)Enum.ToObject(typeof(CryptographicProviderType), headers[AUTHENTICATION_PROVIDER_TYPE_KEY]);
            string connectorType = GetString(headers, CONNECTOR_TYPE_KEY);

            msg.ConnectorType           = new Guid(connectorType);
            msg.DestinationSymmetricKey = (byte[])headers[DESTINATION_SYMMETRIC_KEY_KEY];
            msg.DigitalSignature        = (byte[])headers[DIGITAL_SIGNATURE_KEY];
            msg.EncryptionAlgorithm     = (EncryptionAlgorithm)Enum.ToObject(typeof(EncryptionAlgorithm), headers[ENCRYPTION_ALGORITHM_KEY]);
            msg.Extension     = (byte[])headers[EXTENSION_KEY];
            msg.HashAlgorithm = (HashAlgorithm)Enum.ToObject(typeof(HashAlgorithm), headers[HASH_ALGORITHM_KEY]);
            msg.Label         = GetString(headers, LABEL_KEY);
            msg.Priority      = (MessagePriority)Enum.ToObject(typeof(MessagePriority), result.BasicProperties.Priority);
            msg.Recoverable   = result.BasicProperties.DeliveryMode == PERSISTENT_DELIVERY_MODE;
            if (result.BasicProperties.ReplyTo != null)
            {
                msg.ResponseQueue = new RabbitMQMessageQueue(provider, QueueReference.Parse(result.BasicProperties.ReplyTo), true);
            }
            msg.SenderCertificate  = (byte[])headers[SENDER_CERTIFICATE_KEY];
            msg.TimeToBeReceived   = new TimeSpan((long)headers[TIME_TO_BE_RECEIVED_KEY]);
            msg.TimeToReachQueue   = new TimeSpan((long)headers[TIME_TO_REACH_QUEUE_KEY]);
            msg.UseAuthentication  = (bool)headers[USE_AUTHENTICATION_KEY];
            msg.UseDeadLetterQueue = (bool)headers[USE_DEAD_LETTER_QUEUE_KEY];
            msg.UseEncryption      = (bool)headers[USE_ENCRYPTION_KEY];

            return(msg);
        }