Apache.NMS.ISession.Close()

Here are the examples of the csharp api class Apache.NMS.ISession.Close() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

20 Examples 7

1. Example

Project: spring-net
Source File: MessageUtils.cs
public static void CloseSession(ISession session)
        {
            if (session != null)
            {
                try
                {
                    session.Close();
                }
                catch (NMSException ex)
                {
                    logger.Debug("Could not close NMS ISession", ex);
                }
                catch (Exception ex)
                {
                    // We don't trust the NMS provider: It might throw RuntimeException or Error.
                    logger.Debug("Unexpected exception on closing NMS ISession", ex);
                }
            }
        }

2. Example

Project: spring-net
Source File: CachingConnectionFactory.cs
public override void ResetConnection()
        {
            this.active = false;
            lock (cachedSessions)
            {
                foreach (DictionaryEntry dictionaryEntry in cachedSessions)
                {
                    LinkedList sessionList = (LinkedList) dictionaryEntry.Value;
                    lock (sessionList)
                    {
                        foreach (ISession session in sessionList)
                        {
                            try
                            {
                                session.Close();
                            }
                            catch (Exception ex)
                            {
                                LOG.Trace("Could not close cached NMS Session", ex);
                            }
                        }
                    }
                }
                cachedSessions.Clear();                
            }
            this.active = true;
            // Now proceed with actual closing of the shared Connection...
            base.ResetConnection();
        }

3. Example

Project: nova
Source File: ActiveMQSender.cs
public string close(Dictionary<string, object> parameters)
        {
            try
            { 
                string uri = (string)parameters["uri"];
                string topic = (string)parameters["topic"];
                session.Close();
                connection.Close();

            }
            catch (Exception ex)
            {
                return ex.ToString();
            }

            return null;
        }

4. Example

Project: spring-net
Source File: CachedSession.cs
private void PhysicalClose()
        {
            if (LOG.IsDebugEnabled)
            {
                LOG.Debug("Closing cached Session: " + this.target);
            }
            // Explicitly close all MessageProducers and MessageConsumers that
            // this Session happens to cache...
            try
            {
                foreach (DictionaryEntry entry in cachedProducers)
                {
                    ((IMessageProducer)entry.Value).Close();
                }
                foreach (DictionaryEntry entry in cachedConsumers)
                {
                    ((IMessageConsumer)entry.Value).Close();
                }
            }
            finally
            {
                // Now actually close the Session.
                target.Close();
            }
        }

5. Example

Project: spring-net
Source File: NmsResourceHolder.cs
public virtual void CloseAll()
        {
            foreach (ISession session in sessions)
            {
                try
                {
                    session.Close();
                }
                catch (Exception ex)
                {
                    logger.Debug("Could not close NMS ISession after transaction", ex);
                }
            }
            foreach (IConnection connection in connections)
            {
                ConnectionFactoryUtils.ReleaseConnection(connection, connectionFactory, true);
            }
            this.connections.Clear();
            this.sessions.Clear();
            this.sessionsPerIConnection.Clear();            
        }

6. Example

Project: spring-net
Source File: MessageTemplateTests.cs
private void CloseProducerSessionConnection(IMessageProducer mockProducer)
        {
            mockProducer.Close();
            LastCall.On(mockProducer).Repeat.Once();
            mockSession.Close();
            LastCall.On(mockSession).Repeat.Once();
            mockConnection.Close();
            LastCall.On(mockConnection).Repeat.Once();
        }

7. Example

Project: spring-net
Source File: MessageTemplateTests.cs
[Test]
        public void SessionCallback()
        {
            NmsTemplate template = CreateTemplate();
            template.ConnectionFactory = mockConnectionFactory;
            mockSession.Close();
            LastCall.On(mockSession).Repeat.Once();
            mockConnection.Close();
            LastCall.On(mockConnection).Repeat.Once();

            mocks.ReplayAll();

            template.Execute(session =>
                                 {
                                     bool b = session.Transacted;
                                     return null;
                                 });
            mocks.VerifyAll();
        }

8. Example

Project: spring-net
Source File: NmsTransactionManager.cs
protected override void DoBegin(object transaction, ITransactionDefinition definition)
        {
   /n ..... /n //View Source file for more details /n }

9. Example

Project: spring-net
Source File: MessageTransactionManagerTests.cs
[Test]
        public void SuspendedTransaction()
        {
            IConnectionFactory connectio/n ..... /n //View Source file for more details /n }

10. Example

Project: spring-net
Source File: MessageTransactionManagerTests.cs
[Test]
        public void TransactionSuspension()
        {
            IConnectionFactory connecti/n ..... /n //View Source file for more details /n }

11. Example

Project: spring-net
Source File: MessageTransactionManagerTests.cs
private static void SetupRollbackExpectations(IConnection connection, IConnectionFactory connectionFactory, ISession session)
        {
            Expect.Call(connectionFactory.CreateConnection()).Return(connection).Repeat.Once();
            Expect.Call(connection.CreateSession(AcknowledgementMode.Transactional)).Return(session).Repeat.Once();
            session.Rollback();
            LastCall.On(session).Repeat.Once();
            session.Close();
            LastCall.On(session).Repeat.Once();
            connection.Close();
            LastCall.On(connection).Repeat.Once();
        }

12. Example

Project: spring-net
Source File: MessageTransactionManagerTests.cs
private static void SetupCommitExpectations(IConnection connection, IConnectionFactory connectionFactory, ISession session)
        {
            Expect.Call(connectionFactory.CreateConnection()).Return(connection).Repeat.Once();
            Expect.Call(connection.CreateSession(AcknowledgementMode.Transactional)).Return(session).Repeat.Once();
            session.Commit();
            LastCall.On(session).Repeat.Once();
            session.Close();
            LastCall.On(session).Repeat.Once();
            connection.Close();
            LastCall.On(connection).Repeat.Once();
        }

13. Example

Project: spring-net
Source File: CachingConnectionFactoryTests.cs
[Test]
        public void CachedSession()
        {
            IConnectionFactory connectionFactory = CreateConnectionFactory();

            mocks.ReplayAll();

            CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory();
            cachingConnectionFactory.TargetConnectionFactory = connectionFactory;

            IConnection con1 = cachingConnectionFactory.CreateConnection();

            ISession session1 = con1.CreateSession(AcknowledgementMode.Transactional);        
            TestSession testSession = GetTestSession(session1);
            Assert.AreEqual(1, testSession.CreatedCount);
            Assert.AreEqual(0, testSession.CloseCount);


            session1.Close();  // won't close, will put in session cache.
            Assert.AreEqual(0, testSession.CloseCount);
            
            ISession session2 = con1.CreateSession(AcknowledgementMode.Transactional);


            TestSession testSession2 = GetTestSession(session2);
            

            Assert.AreSame(testSession, testSession2);

            Assert.AreEqual(1, testSession.CreatedCount);
            Assert.AreEqual(0, testSession.CloseCount);
           
            mocks.VerifyAll();

            //don't explicitly call close on 
        }

14. Example

Project: spring-net
Source File: CachingConnectionFactoryTests.cs
[Test]
        public void CachedMessageProducer()
        {
            IConnectionFactory connectionFactory = CreateConnectionFactory();
            
            mocks.ReplayAll();


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

            ISession sessionA = con1.CreateSession(AcknowledgementMode.Transactional);
            IMessageProducer producerA = sessionA.CreateProducer();
            TestMessageProducer tmpA = GetTestMessageProducer(producerA);

            sessionA.Close();

            ISession sessionB = con1.CreateSession(AcknowledgementMode.Transactional);
            IMessageProducer producerB = sessionB.CreateProducer();
            TestMessageProducer tmpB = GetTestMessageProducer(producerB);
            
            Assert.AreSame(tmpA, tmpB);

            mocks.VerifyAll();
        }

15. Example

Project: spring-net
Source File: CachingConnectionFactoryTests.cs
[Test]
        public void CachedMessageConsumer()
        {
            IConnectionFactory connectionFactory = CreateConnectionFactory();

            mocks.ReplayAll();


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

            ISession sessionA = con1.CreateSession(AcknowledgementMode.Transactional);
            IDestination destination = new ActiveMQQueue("test.dest");
            IMessageConsumer consumerA = sessionA.CreateConsumer(destination);
            TestMessageConsumer tmpA = GetTestMessageConsumer(consumerA);

            sessionA.Close();

            ISession sessionB = con1.CreateSession(AcknowledgementMode.Transactional);
            IMessageConsumer consumerB = sessionB.CreateConsumer(destination);
            TestMessageConsumer tmpB = GetTestMessageConsumer(consumerB);

            Assert.AreSame(tmpA, tmpB);            
            mocks.VerifyAll();
        }

16. Example

Project: spring-net
Source File: ConnectionFactoryUtils.cs
public static ISession DoGetTransactionalSession(Object resourceKey, ResourceFactory resourceFactory/n ..... /n //View Source file for more details /n }

17. Example

Project: spring-net
Source File: CachingConnectionFactoryTests.cs
[Test]
        public void CachedSessionTwoRequests()
        {
            IConnectionFactory conne/n ..... /n //View Source file for more details /n }

18. Example

Project: spring-net
Source File: CachingConnectionFactoryTests.cs
[Test]
        public void CachedMessageProducerTwoRequests()
        {
            IConnectionFactory connectionFactory = CreateConnectionFactory();

            mocks.ReplayAll();


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

            ISession sessionA = con1.CreateSession(AcknowledgementMode.Transactional);
            IMessageProducer producerA = sessionA.CreateProducer();
            TestMessageProducer tmpA = GetTestMessageProducer(producerA);

           
            ISession sessionB = con1.CreateSession(AcknowledgementMode.Transactional);
            IMessageProducer producerB = sessionB.CreateProducer();
            TestMessageProducer tmpB = GetTestMessageProducer(producerB);
            
            Assert.AreNotSame(tmpA, tmpB);

            sessionA.Close();

            ISession sessionC = con1.CreateSession(AcknowledgementMode.Transactional);
            IMessageProducer producerC = sessionC.CreateProducer();
            TestMessageProducer tmpC = GetTestMessageProducer(producerC);

            Assert.AreSame(tmpA, tmpC);

            mocks.VerifyAll();
        }

19. Example

Project: spring-net
Source File: SingleConnectionFactoryTests.cs
[Test]
        public void CachingConnectionFactory()
        {
            IConnectionFactory conne/n ..... /n //View Source file for more details /n }

20. Example

Project: spring-net
Source File: MessageTemplateTests.cs
[Test]
        public void SessionCallbackWithinSynchronizedTransaction()
        {
            Sing/n ..... /n //View Source file for more details /n }