public void MessageQueueNameNotInContext()
        {
            MessageQueueTemplate q = new MessageQueueTemplate("noqueuename");

            q.ApplicationContext = applicationContext;
            q.AfterPropertiesSet();
        }
        public void MessageQueueCreatedinThreadLocalStorage()
        {
            MessageQueueTemplate q = applicationContext["queue"] as MessageQueueTemplate;

            Assert.IsNotNull(q);
            Assert.AreEqual(q.DefaultMessageQueue, q.MessageQueueFactory.CreateMessageQueue(q.DefaultMessageQueueObjectName));
        }
        public void MessageCreator()
        {
            MessageQueueTemplate mqt = applicationContext["txqueue"] as MessageQueueTemplate;

            Assert.IsNotNull(mqt);
            string path = @".\Private$\mlptestqueue";

            if (MessageQueue.Exists(path))
            {
                MessageQueue.Delete(path);
            }
            MessageQueue.Create(path, true);
            mqt.MessageQueueFactory.RegisterMessageQueue("newQueueDefinition", delegate
            {
                MessageQueue mq = new MessageQueue();
                mq.Path         = path;
                // other properties
                return(mq);
            });

            Assert.IsTrue(mqt.MessageQueueFactory.ContainsMessageQueue("newQueueDefinition"));

            SendAndReceive("newQueueDefinition", mqt);

            SimpleCreator sc = new SimpleCreator();

            mqt.MessageQueueFactory.RegisterMessageQueue("fooQueueDefinition", sc.CreateQueue);
        }
        public void MessageQueueNameNotInContext()
        {
            MessageQueueTemplate q = new MessageQueueTemplate("noqueuename");

            q.ApplicationContext = applicationContext;
            Assert.Throws <ArgumentException>(() => q.AfterPropertiesSet(), "No object named noqueuename is defined in the Spring container");
        }
        public void SendTxMessageQueueUsingMessageTx()
        {
            MessageQueueTemplate q = applicationContext["txqueue"] as MessageQueueTemplate;

            Assert.IsNotNull(q);
            SendAndReceive(q);
        }
        public void SendAndReceiveNonTransactionalRemotePrivateQueue()
        {
            MessageQueueTemplate q = applicationContext["queueTemplate-remote"] as MessageQueueTemplate;

            Assert.IsNotNull(q);
            q.ConvertAndSend("Hello World 1");
            //ReceiveHelloWorld(null, q, 1);
        }
        public void GetAllFromQueue()
        {
            MessageQueueTemplate q = applicationContext["queue"] as MessageQueueTemplate;

            Assert.IsNotNull(q);
            for (int i = 0; i < 5; i++)
            {
                Console.WriteLine(q.ReceiveAndConvert());
            }
        }
        private static void SendUsingMessageTxScope(MessageQueueTemplate q)
        {
            IPlatformTransactionManager txManager           = new TxScopeTransactionManager();
            TransactionTemplate         transactionTemplate = new TransactionTemplate(txManager);

            transactionTemplate.Execute(status =>
            {
                q.ConvertAndSend("Hello World 1");
                q.ConvertAndSend("Hello World 2");
                q.ConvertAndSend("Hello World 3");
                return(null);
            });
        }
        private static void ReceiveHelloWorld(string messageQueueObjectName, MessageQueueTemplate q, int index)
        {
            object o = null;

            if (messageQueueObjectName == null)
            {
                o = q.ReceiveAndConvert();
            }
            else
            {
                o = q.ReceiveAndConvert(messageQueueObjectName);
            }
            Assert.IsNotNull(o);
            string data = o as string;

            Assert.IsNotNull(data);
            Assert.AreEqual("Hello World " + index, data);
        }
        private static void SendUsingMessageTx(string messageQueueObjectName, MessageQueueTemplate q)
        {
            IPlatformTransactionManager txManager           = new MessageQueueTransactionManager();
            TransactionTemplate         transactionTemplate = new TransactionTemplate(txManager);

            transactionTemplate.Execute(status =>
            {
                if (messageQueueObjectName == null)
                {
                    q.ConvertAndSend("Hello World 1");
                    q.ConvertAndSend("Hello World 2");
                    q.ConvertAndSend("Hello World 3");
                }
                else
                {
                    q.ConvertAndSend(messageQueueObjectName, "Hello World 1");
                    q.ConvertAndSend(messageQueueObjectName, "Hello World 2");
                    q.ConvertAndSend(messageQueueObjectName, "Hello World 3");
                }
                return(null);
            });
        }
        public void NoMessageQueueNameSpecified()
        {
            MessageQueueTemplate mqt = new MessageQueueTemplate();

            mqt.AfterPropertiesSet();
        }
 public void MessageQueueNameNotInContext()
 {
     MessageQueueTemplate q = new MessageQueueTemplate("noqueuename");
     q.ApplicationContext = applicationContext;
     Assert.Throws<ArgumentException>(() => q.AfterPropertiesSet(), "No object named noqueuename is defined in the Spring container");
 }
 public void NoMessageQueueNameSpecified()
 {
     MessageQueueTemplate mqt = new MessageQueueTemplate();
     Assert.Throws<ArgumentNullException>(() => mqt.AfterPropertiesSet());
 }
 /// <summary>
 /// Invoked by an <see cref="Spring.Objects.Factory.IObjectFactory"/>
 /// after it has injected all of an object's dependencies.
 /// </summary>
 /// <remarks>
 /// 	<p>
 /// This method allows the object instance to perform the kind of
 /// initialization only possible when all of it's dependencies have
 /// been injected (set), and to throw an appropriate exception in the
 /// event of misconfiguration.
 /// </p>
 /// 	<p>
 /// Please do consult the class level documentation for the
 /// <see cref="Spring.Objects.Factory.IObjectFactory"/> interface for a
 /// description of exactly <i>when</i> this method is invoked. In
 /// particular, it is worth noting that the
 /// <see cref="Spring.Objects.Factory.IObjectFactoryAware"/>
 /// and <see cref="Spring.Context.IApplicationContextAware"/>
 /// callbacks will have been invoked <i>prior</i> to this method being
 /// called.
 /// </p>
 /// </remarks>
 /// <exception cref="System.Exception">
 /// In the event of misconfiguration (such as the failure to set a
 /// required property) or if initialization fails.
 /// </exception>
 public void AfterPropertiesSet()
 {
     if (messageQueueFactory == null)
     {
         DefaultMessageQueueFactory mqf = new DefaultMessageQueueFactory();
         mqf.ApplicationContext = applicationContext;
         messageQueueFactory = mqf;
     }
     if (messageConverterObjectName == null)
     {
         messageConverterObjectName = QueueUtils.RegisterDefaultMessageConverter(applicationContext);
     }
     if (messageQueueTemplate == null)
     {
         messageQueueTemplate = new MessageQueueTemplate();
         messageQueueTemplate.ApplicationContext = ApplicationContext;
         messageQueueTemplate.AfterPropertiesSet();
     }
 }
 public void MessageQueueNameNotInContext()
 {
     MessageQueueTemplate q = new MessageQueueTemplate("noqueuename");
     q.ApplicationContext = applicationContext;
     q.AfterPropertiesSet();
 }
 private static void SendUsingMessageTxScope(MessageQueueTemplate q)
 {
     IPlatformTransactionManager txManager = new TxScopeTransactionManager();
     TransactionTemplate transactionTemplate = new TransactionTemplate(txManager);
     transactionTemplate.Execute(status =>
                                     {
                                         q.ConvertAndSend("Hello World 1");
                                         q.ConvertAndSend("Hello World 2");
                                         q.ConvertAndSend("Hello World 3");
                                         return null;
                                     });
 }
 private static void Receive(string messageQueueObjectName, MessageQueueTemplate q)
 {
     ReceiveHelloWorld(messageQueueObjectName, q, 1);
     ReceiveHelloWorld(messageQueueObjectName, q, 2);
     ReceiveHelloWorld(messageQueueObjectName, q, 3);
 }
 private static void SendAndReceive(MessageQueueTemplate q)
 {
     SendAndReceive(null, q);
 }
 private static void ReceiveHelloWorld(string messageQueueObjectName, MessageQueueTemplate q, int index)
 {
     object o = null;
     if (messageQueueObjectName == null)
     {
         o = q.ReceiveAndConvert();
     } else
     {
         o = q.ReceiveAndConvert(messageQueueObjectName);
     }
     Assert.IsNotNull(o);
     string data = o as string;
     Assert.IsNotNull(data);
     Assert.AreEqual("Hello World " + index, data);
 }
 private static void SendAndReceive(MessageQueueTemplate q)
 {
     SendAndReceive(null, q);
 }
 private static void SendAndReceive(string messageQueueObjectName, MessageQueueTemplate q)
 {
     SendUsingMessageTx(messageQueueObjectName, q);
     Receive(messageQueueObjectName, q);
 }
 private static void SendAndReceive(string messageQueueObjectName, MessageQueueTemplate q)
 {
     SendUsingMessageTx(messageQueueObjectName, q);
     Receive(messageQueueObjectName, q);
 }
 private static void SendUsingMessageTx(string messageQueueObjectName, MessageQueueTemplate q)
 {
     IPlatformTransactionManager txManager = new MessageQueueTransactionManager();
     TransactionTemplate transactionTemplate = new TransactionTemplate(txManager);
     transactionTemplate.Execute(status =>
                                     {
                                         if (messageQueueObjectName == null)
                                         {
                                             q.ConvertAndSend("Hello World 1");
                                             q.ConvertAndSend("Hello World 2");
                                             q.ConvertAndSend("Hello World 3");
                                         } else
                                         {
                                             q.ConvertAndSend(messageQueueObjectName, "Hello World 1");
                                             q.ConvertAndSend(messageQueueObjectName, "Hello World 2");
                                             q.ConvertAndSend(messageQueueObjectName, "Hello World 3");
                                         }
                                         return null;
                                     });
 }
 private static void Receive(string messageQueueObjectName, MessageQueueTemplate q)
 {
     ReceiveHelloWorld(messageQueueObjectName, q, 1);
     ReceiveHelloWorld(messageQueueObjectName, q, 2);
     ReceiveHelloWorld(messageQueueObjectName, q, 3);
 }
 public void NoMessageQueueNameSpecified()
 {
     MessageQueueTemplate mqt = new MessageQueueTemplate();
     mqt.AfterPropertiesSet();
 }
        public void NoMessageQueueNameSpecified()
        {
            MessageQueueTemplate mqt = new MessageQueueTemplate();

            Assert.Throws <ArgumentNullException>(() => mqt.AfterPropertiesSet());
        }