Exemplo n.º 1
0
 public ITopicSubscriber CreateDurableSubscriber(Topic topic, string name, string messageSelector, bool noLocal)
 {
     return new EmsTopicSubscriber(nativeSession.CreateDurableSubscriber(topic, name, messageSelector, noLocal));
 }
Exemplo n.º 2
0
 public ITopicSubscriber CreateDurableSubscriber(Topic topic, string name, string messageSelector, bool noLocal)
 {
     return new TestTopicSubscriber();
 }
Exemplo n.º 3
0
 public ITopicSubscriber CreateDurableSubscriber(Topic topic, string name)
 {
     return new EmsTopicSubscriber(nativeSession.CreateDurableSubscriber(topic, name));
 }
Exemplo n.º 4
0
 public ITopicSubscriber CreateDurableSubscriber(Topic topic, string name)
 {
     return new TestTopicSubscriber();
 }
        public void CachedMessageConsumer()
        {
            IConnectionFactory connectionFactory = (IConnectionFactory)mocks.CreateMock(typeof(IConnectionFactory));
            IConnection connection = new TestConnection();
            

            Expect.Call(connectionFactory.CreateConnection()).Return(connection).Repeat.Once();

            mocks.ReplayAll();


            CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory();
            cachingConnectionFactory.TargetConnectionFactory = connectionFactory;
            IConnection con1 = cachingConnectionFactory.CreateConnection();

            ISession sessionA = con1.CreateSession(true, SessionMode.SessionTransacted);
            Destination destination = new Topic("test.dest");
            IMessageConsumer consumerA = sessionA.CreateConsumer(destination);
            TestMessageConsumer tmpA = GetTestMessageConsumer(consumerA);

            sessionA.Close();

            ISession sessionB = con1.CreateSession(true, SessionMode.SessionTransacted);
            IMessageConsumer consumerB = sessionB.CreateConsumer(destination);
            TestMessageConsumer tmpB = GetTestMessageConsumer(consumerB);

            Assert.AreSame(tmpA, tmpB);

            mocks.VerifyAll();
        }
        public void CachedMessageProducerTwoRequests()
        {
            IConnectionFactory connectionFactory = (IConnectionFactory)mocks.CreateMock(typeof(IConnectionFactory));
            IConnection connection = new TestConnection();

            Expect.Call(connectionFactory.CreateConnection()).Return(connection).Repeat.Once();

            mocks.ReplayAll();


            CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory();
            cachingConnectionFactory.TargetConnectionFactory = connectionFactory;
            IConnection con1 = cachingConnectionFactory.CreateConnection();

            ISession sessionA = con1.CreateSession(true, SessionMode.SessionTransacted);
            Topic dest = new Topic("test.topic");
            IMessageProducer producerA = sessionA.CreateProducer(dest);
            TestMessageProducer tmpA = GetTestMessageProducer(producerA);


            ISession sessionB = con1.CreateSession(true, SessionMode.SessionTransacted);
            IMessageProducer producerB = sessionB.CreateProducer(dest);
            TestMessageProducer tmpB = GetTestMessageProducer(producerB);
            
            Assert.AreNotSame(tmpA, tmpB);

            sessionA.Close();

            ISession sessionC = con1.CreateSession(true, SessionMode.SessionTransacted);
            IMessageProducer producerC = sessionC.CreateProducer(dest);
            TestMessageProducer tmpC = GetTestMessageProducer(producerC);

            Assert.AreSame(tmpA, tmpC);

            mocks.VerifyAll();
        }
Exemplo n.º 7
0
 /// <summary>
 /// Creates the durable consumer, potentially returning a cached instance.
 /// </summary>
 /// <param name="destination">The destination.</param>
 /// <param name="subscription">The name of the durable subscription.</param>
 /// <returns>A message consumer</returns>
 public ITopicSubscriber CreateDurableSubscriber(Topic destination, string subscription)
 {
     return CreateDurableSubscriber(destination, subscription, null, false);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Creates the durable consumer, potentially returning a cached instance.
 /// </summary>
 /// <param name="destination">The destination.</param>
 /// <param name="subscription">The name of the durable subscription.</param>
 /// <param name="selector">The selector.</param>
 /// <param name="noLocal">if set to <c>true</c> [no local].</param>
 /// <returns>A message consumer</returns>
 public ITopicSubscriber CreateDurableSubscriber(Topic destination, string subscription, string selector, bool noLocal)
 {
     this.transactionOpen = true;
     if (shouldCacheConsumers)
     {
         return (ITopicSubscriber)GetCachedConsumer(destination, selector, noLocal, subscription);
     }
     else
     {
         return target.CreateDurableSubscriber(destination, subscription, selector, noLocal);
     }
 }