public static MessageQueue Create(string path)
        {
            QueueReference qRef          = QueueReference.Parse(path);
            IMessageQueue  iMessageQueue = CreateMessageQueue(qRef, false);

            return(new MessageQueue(iMessageQueue));
        }
예제 #2
0
        private static IConnection CreateConnection(QueueReference qRef)
        {
            ConnectionFactory cf = new ConnectionFactory();

            cf.Address = qRef.Host;
            return(cf.CreateConnection());
        }
예제 #3
0
 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 static MessageQueue Create(string path, bool transactional)
        {
            QueueReference qRef          = QueueReference.Parse(path);
            IMessageQueue  iMessageQueue = CreateMessageQueue(qRef,
                                                              transactional);

            return(new MessageQueue(iMessageQueue));
        }
        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");
        }
예제 #6
0
        public static void Delete(QueueReference qRef)
        {
            RabbitMQMessagingProvider provider = (RabbitMQMessagingProvider)MessagingProviderLocator.GetProvider();

            using (IMessagingContext context = provider.CreateContext(qRef.Host)) {
                context.Delete(qRef);
            }
        }
예제 #7
0
		public RabbitMQMessageQueue (RabbitMQMessagingProvider provider,
		                             QueueReference qRef, 
		                             bool transactional)
		{
			this.provider = provider;
			this.helper = new MessageFactory (provider);
			this.qRef = qRef;
			this.transactional = transactional;
		}
예제 #8
0
 public bool Exists(QueueReference qRef)
 {
     qLock.AcquireReaderLock(TIMEOUT);
     try {
         return(queues.Contains(qRef));
     } finally {
         qLock.ReleaseReaderLock();
     }
 }
        private static IMessageQueue GetMessageQueue(string path)
        {
            QueueReference qRef = QueueReference.Parse(path);
            IMessageQueue  q    = MessagingProviderLocator
                                  .GetProvider()
                                  .GetMessageQueue(qRef);

            return(q);
        }
예제 #10
0
 public static void Delete(QueueReference qRef)
 {
     using (IConnection cn = CreateConnection(qRef))
     {
         using (IModel model = cn.CreateModel())
         {
             model.QueueDelete(qRef.Queue, false, false, false);
         }
     }
 }
예제 #11
0
		public static void Delete (QueueReference qRef)
		{
			ConnectionFactory cf = new ConnectionFactory ();
			
			using (IConnection cn = cf.CreateConnection (qRef.Host)) {
				using (IModel model = cn.CreateModel ()) {
					model.QueueDelete (qRef.Queue, false, false, false);
				}
			}
		}			
예제 #12
0
        public void Send(QueueReference qRef, IMessage message)
        {
            IModel _model = Model;

            string          finalName = _model.QueueDeclare(qRef.Queue, false);
            IMessageBuilder mb        = helper.WriteMessage(_model, message);

            model.BasicPublish("", finalName,
                               (IBasicProperties)mb.GetContentHeader(),
                               mb.GetContentBody());
        }
예제 #13
0
 public IMessage Receive(QueueReference qRef, TimeSpan timeout, IsMatch matcher, bool ack)
 {
     if (matcher == null)
     {
         return(Receive(qRef, MessageFactory.TimeSpanToMillis(timeout), ack));
     }
     else
     {
         return(ReceiveWithMatcher(qRef, MessageFactory.TimeSpanToMillis(timeout), matcher, ack));
     }
 }
예제 #14
0
        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));
            }
        }
예제 #15
0
 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");
     }
 }
예제 #16
0
 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();
     }
 }
예제 #17
0
        public void Send(QueueReference qRef, IMessage msg)
        {
            lock (syncObj) {
                ValidateHost(qRef);

                Model.TxSelect();
                isActive = true;


                Context.Send(qRef, msg);
            }
        }
예제 #18
0
        private IMessage Receive(QueueReference qRef, int timeout, bool ack)
        {
            IModel _model = Model;

            string finalName = _model.QueueDeclare(qRef.Queue, false);

            using (Subscription sub = new Subscription(_model, finalName)) {
                BasicDeliverEventArgs result;
                if (sub.Next(timeout, out result))
                {
                    IMessage m = helper.ReadMessage(qRef, result);
                    if (ack)
                    {
                        sub.Ack(result);
                    }
                    return(m);
                }
                else
                {
                    throw new MonoMessagingException("No Message Available");
                }
            }
        }
예제 #19
0
        private IMessage ReceiveWithMatcher(QueueReference qRef, int timeout, IsMatch matcher, bool ack)
        {
            IModel _model = Model;

            string finalName = _model.QueueDeclare(qRef.Queue, false);

            using (Subscription sub = new Subscription(_model, finalName)) {
                BasicDeliverEventArgs result;
                while (sub.Next(timeout, out result))
                {
                    if (matcher(result))
                    {
                        IMessage m = helper.ReadMessage(qRef, result);
                        if (ack)
                        {
                            sub.Ack(result);
                        }
                        return(m);
                    }
                }

                throw new MessageUnavailableException("Message not available");
            }
        }
        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);
        }
예제 #21
0
		private IMessage Receive (QueueReference qRef, int timeout, bool ack)
		{
			IModel _model = Model;
			
			string finalName = _model.QueueDeclare (qRef.Queue, false);
			using (Subscription sub = new Subscription (_model, finalName)) {
				BasicDeliverEventArgs result;
				if (sub.Next (timeout, out result)) {
					IMessage m = helper.ReadMessage (qRef, result);
					if (ack)
						sub.Ack (result);
					return m;
				} else {
					throw new MonoMessagingException ("No Message Available");
				}
			}
		}
예제 #22
0
		private IMessage ReceiveWithMatcher (QueueReference qRef, int timeout, IsMatch matcher, bool ack)
		{
			IModel _model = Model;
			
			string finalName = _model.QueueDeclare (qRef.Queue, false);
			using (Subscription sub = new Subscription (_model, finalName)) {
				BasicDeliverEventArgs result;
				while (sub.Next (timeout, out result)) {
					
					if (matcher (result)) {
						IMessage m = helper.ReadMessage (qRef, result);
						if (ack)
							sub.Ack (result);
						return m;
					}
				}
				
				throw new MessageUnavailableException ("Message not available");
			}
		}
예제 #23
0
 public void DeleteQueue(QueueReference qRef)
 {
     throw new NotImplementedException();
 }
예제 #24
0
 public void Purge(QueueReference qRef)
 {
     lock (syncObj) {
         Context.Purge(qRef);
     }
 }
        public static void Delete(string path)
        {
            QueueReference qRef = QueueReference.Parse(path);

            MessagingProviderLocator.GetProvider().DeleteQueue(qRef);
        }
 public void StringLeadingChars()
 {
     Assert.AreEqual(@"asdfb\asdfasd",
                     QueueReference.RemoveLeadingSlashes(@"\\asdfb\asdfasd"),
                     "Failed to removed slashes");
 }
예제 #27
0
		public void Send (QueueReference qRef, IMessage message)
		{
			IModel _model = Model;
			
			string finalName = _model.QueueDeclare (qRef.Queue, false);
			IMessageBuilder mb = helper.WriteMessage (_model, message);
			
			model.BasicPublish ("", finalName,
				(IBasicProperties) mb.GetContentHeader (),
				mb.GetContentBody ());
		}
예제 #28
0
		private static IConnection CreateConnection (QueueReference qRef)
		{
			ConnectionFactory cf = new ConnectionFactory ();
			cf.Address = qRef.Host;
			return cf.CreateConnection ();
		}		
예제 #29
0
		public void Delete (QueueReference qRef)
		{
			Model.QueueDelete (qRef.Queue, false, false, false);
		}
예제 #30
0
		public IMessage Receive (QueueReference qRef, TimeSpan timeout, IsMatch matcher, bool ack)
		{
			if (matcher == null)
			{
				return Receive (qRef, MessageFactory.TimeSpanToMillis (timeout), ack);
			}
			else
			{
				return ReceiveWithMatcher (qRef, MessageFactory.TimeSpanToMillis (timeout), matcher, ack);
			}
		}
예제 #31
0
		public static void Delete (QueueReference qRef)
		{
			RabbitMQMessagingProvider provider = (RabbitMQMessagingProvider) MessagingProviderLocator.GetProvider ();
			using (IMessagingContext context = provider.CreateContext (qRef.Host)) {
				context.Delete (qRef);
			}
		}			
예제 #32
0
 public void DeleteQueue(QueueReference qRef)
 {
     RabbitMQMessageQueue.Delete(qRef);
 }
 private static bool Exists(QueueReference qRef)
 {
     return(MessagingProviderLocator.GetProvider().Exists(qRef));
 }
예제 #34
0
 public void Delete(QueueReference qRef)
 {
     lock (syncObj) {
         Context.Delete(qRef);
     }
 }
예제 #35
0
		public void Purge (QueueReference qRef)
		{
			Model.QueuePurge (qRef.Queue, false);
		}
 public static bool Exists(string path)
 {
     return(Exists(QueueReference.Parse(path)));
 }
 private static IMessageQueue CreateMessageQueue(QueueReference qRef,
                                                 bool transactional)
 {
     return(MessagingProviderLocator.GetProvider()
            .CreateMessageQueue(qRef, transactional));
 }
 public RabbitMQMessageEnumerator(MessageFactory helper,
                                  QueueReference qRef)
 {
     this.helper = helper;
     this.qRef   = qRef;
 }
예제 #39
0
		public static void Delete (QueueReference qRef)
		{
			using (IConnection cn = CreateConnection (qRef)) {
				using (IModel model = cn.CreateModel ()) {
					model.QueueDelete (qRef.Queue, false, false, false);
				}
			}
		}