示例#1
0
		public void Equals ()
		{
			QueueReference qr1 = new QueueReference ("abc", "def", false);
			QueueReference qr2 = new QueueReference ("abc", "def", false);
			//Assert.IsTrue(qr1.Equals(qr2), "QueueReferences should be equal");
			Assert.AreEqual (qr1, qr2, "QueueReferences should be equal");
		}
		public IMessage Receive (QueueReference qRef, TimeSpan timeout, IsMatch matcher, bool ack)
		{
			lock (syncObj) {
				ValidateHost (qRef);
					
				Model.TxSelect ();
				isActive = true;
				
				return Context.Receive (qRef, timeout, matcher, ack);
			}
		}	
示例#3
0
 public override bool Equals(object other)
 {
     if (other == null)
     {
         return(false);
     }
     else if (typeof(QueueReference) != other.GetType())
     {
         return(false);
     }
     else
     {
         QueueReference qr = (QueueReference)other;
         return(Equals(qr));
     }
 }
		public IMessageQueue CreateMessageQueue (QueueReference qRef,
		                                         bool transactional)
		{
			qLock.AcquireWriterLock (TIMEOUT);
			try {
				IMessageQueue mq = new RabbitMQMessageQueue (this, qRef, transactional);
				queues[qRef] = mq;
				return mq;
			} finally {
				qLock.ReleaseWriterLock ();
			}
		}
		public bool Exists (QueueReference qRef)
		{
			qLock.AcquireReaderLock (TIMEOUT);
			try {
				return queues.Contains (qRef);
			} finally {
				qLock.ReleaseReaderLock ();
			}
		}
示例#6
0
		private static IMessageQueue CreateMessageQueue (QueueReference qRef,
		                                                 bool transactional)
		{
			return MessagingProviderLocator.GetProvider ()
				.CreateMessageQueue (qRef, transactional);
		}
示例#7
0
 public ConnectionException(QueueReference qRef)
     : base("Unable to connect to Queue: " + qRef)
 {
     this.qRef = qRef;
 }
		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;
		}
		public RabbitMQMessageEnumerator (MessageFactory helper,
		                                  QueueReference qRef) {
			this.helper = helper;
			this.qRef = qRef;
		}
示例#10
0
 public void DeleteQueue(QueueReference qRef)
 {
     throw new NotImplementedException ();
 }
示例#11
0
 public IMessageQueue CreateMessageQueue(QueueReference qRef, bool transactional)
 {
     throw new NotImplementedException ();
 }
		public void Send (QueueReference qRef, IMessage msg)
		{
			lock (syncObj) {
				ValidateHost (qRef);
				
				Model.TxSelect ();
				isActive = true;
				
				
				Context.Send (qRef, msg);
			}
		}
		public void Purge (QueueReference qRef)
		{
			lock (syncObj) {
				Context.Purge (qRef);
			}
		}
		public void Delete (QueueReference qRef)
		{
			lock (syncObj) {
				Context.Delete (qRef);
			}
		}
		private void ValidateHost (QueueReference qRef)
		{
			if (null == host) {
				host = qRef.Host;
			} else if (host != qRef.Host) {
				throw new MonoMessagingException ("Transactions can not span multiple hosts");
			}
		}
		public IMessageQueue GetMessageQueue (QueueReference qRef)
		{
			qLock.AcquireReaderLock (TIMEOUT);
			try {
				if (queues.Contains (qRef))
					return (IMessageQueue) queues[qRef];
				else {
					LockCookie lc = qLock.UpgradeToWriterLock (TIMEOUT);
					try {
						IMessageQueue mq = new RabbitMQMessageQueue (this, qRef, false);
						queues[qRef] = mq;
						return mq;
					} finally {
						qLock.DowngradeFromWriterLock (ref lc);
					}
				}
			} finally {
				qLock.ReleaseReaderLock ();
			}
		}
		public void DeleteQueue (QueueReference qRef)
		{
			RabbitMQMessageQueue.Delete (qRef);
		}
示例#18
0
 public bool Exists(QueueReference qRef)
 {
     throw new NotImplementedException ();
 }
		public ConnectionException (QueueReference qRef) 
			: base ("Unable to connect to Queue")
		{
			this.qRef = qRef;
		}
示例#20
0
 public IMessageQueue GetMessageQueue(QueueReference qRef)
 {
     throw new NotImplementedException ();
 }
示例#21
0
 public ConnectionException(QueueReference qRef, Exception e)
     : base("Unable to connect to Queue: " + qRef + ", Error: " + e.Message, e)
 {
     this.qRef = qRef;
 }
示例#22
0
		public ConnectionException (QueueReference qRef, Exception e) 
			: base ("Unable to connect to Queue: " + qRef + ", Error: " + e.Message, e)
		{
			this.qRef = qRef;
		}
示例#23
0
		public bool Equals (QueueReference other)
		{
			return host == other.host 
				&& isPrivate == other.isPrivate
				&& queue == other.queue;
		}
示例#24
0
 public ConnectionException(QueueReference qRef, Exception e)
     : base("Unable to connect to Queue", e)
 {
     this.qRef = qRef;
 }
示例#25
0
		private static bool Exists (QueueReference qRef)
		{
			return MessagingProviderLocator.GetProvider ().Exists (qRef);
		}		
示例#26
0
 public bool Equals(QueueReference other)
 {
     return(host == other.host &&
            isPrivate == other.isPrivate &&
            queue == other.queue);
 }