Apache.NMS.IConnection.Close()

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

18 Examples 7

1. Example

Project: spring-net
Source File: ConnectionFactoryUtils.cs
public static void ReleaseConnection(IConnection connection, IConnectionFactory cf, bool started)
        {
            if (connection == null)
            {
                return;
            }

            if (started && cf is ISmartConnectionFactory && ((ISmartConnectionFactory)cf).ShouldStop(connection))
            {
                try
                {
                    connection.Stop();
                }
                catch (Exception ex)
                {
                    LOG.Debug("Could not stop NMS Connection before closing it", ex);

                }
            }
            try
            {
                connection.Close();
            } catch (Exception ex)
            {
                LOG.Debug("Could not close NMS Connection", ex);
            }           
        }

2. Example

Project: spring-net
Source File: SingleConnectionFactory.cs
protected virtual void CloseConnection(IConnection con)
        {
            if (LOG.IsDebugEnabled)
            {
                LOG.Debug("Closing shared NMS Connection: " + this.target);
            }
            try
            {
                try
                {
                    if (this.started)
                    {
                        this.started = false;
                        con.Stop();                        
                    }
                } finally
                {
                    con.Close();
                }
            } catch (Exception ex)
            {
                LOG.Warn("Could not close shared NMS connection.", ex);
            }
        }

3. Example

Project: spring-net
Source File: MessageUtils.cs
public static void CloseConnection(IConnection con, bool stop)
        {
            if (con != null)
            {
                try
                {
                    if (stop)
                    {
                        try
                        {
                            con.Stop();
                        }
                        finally
                        {
                            con.Close();
                        }
                    }
                    else
                    {
                        con.Close();
                    }
                }
                catch (NMSException ex)
                {
                    logger.Debug("Could not close NMS Connection", ex);
                }
                catch (Exception ex)
                {
                    // We don't trust the NMS provider: It might throw another exception.
                    logger.Debug("Unexpected exception on closing NMS Connection", ex);
                }
            }
        }

4. 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;
        }

5. 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();
        }

6. 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();
        }

7. 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 }

8. Example

Project: spring-net
Source File: SingleConnectionFactoryTests.cs
[Test]
        public void UsingConnection()
        {
            IConnection connection = mocks.StrictMock<IConnection>();

            connection.Start();
            LastCall.On(connection).Repeat.Twice();
            connection.PurgeTempDestinations();
            LastCall.On( connection ).Repeat.Twice();
            connection.Stop();
            LastCall.On(connection).Repeat.Once();
            connection.Close();
            LastCall.On(connection).Repeat.Once();

            mocks.ReplayAll();
            
            SingleConnectionFactory scf = new SingleConnectionFactory(connection);
            IConnection con1 = scf.CreateConnection();
            con1.Start();
            con1.PurgeTempDestinations();
            con1.Stop(); // should be ignored
            con1.Close(); // should be ignored
            IConnection con2 = scf.CreateConnection();
            con2.Start();
            con1.PurgeTempDestinations();
            con2.Stop(); // should be ignored
            con2.Close(); // should be ignored.
            scf.Dispose();

            mocks.VerifyAll();
        }

9. Example

Project: spring-net
Source File: SingleConnectionFactoryTests.cs
[Test]
        public void UsingConnectionFactory()
        {
            IConnectionFactory connectionFactory = (IConnectionFactory)mocks.StrictMock<IConnectionFactory>();
            IConnection connection = mocks.StrictMock<IConnection>();

            Expect.Call(connectionFactory.CreateConnection()).Return(connection).Repeat.Once();
            connection.Start();
            LastCall.On(connection).Repeat.Twice();
            connection.Stop();
            LastCall.On(connection).Repeat.Once();
            connection.Close();
            LastCall.On(connection).Repeat.Once();


            mocks.ReplayAll();

            SingleConnectionFactory scf = new SingleConnectionFactory(connectionFactory);
            IConnection con1 = scf.CreateConnection();
            con1.Start();
            con1.Close(); // should be ignored
            IConnection con2 = scf.CreateConnection();
            con2.Start();
            con2.Close();   //should be ignored
            scf.Dispose();  //should trigger actual close

            mocks.VerifyAll();

        }

10. Example

Project: spring-net
Source File: SingleConnectionFactoryTests.cs
[Test]
        public void UsingConnectionFactoryAndClientId()
        {
            IConnectionFactory connectionFactory = mocks.StrictMock<IConnectionFactory>();
            IConnection connection = mocks.StrictMock<IConnection>();

            Expect.Call(connectionFactory.CreateConnection()).Return(connection).Repeat.Once();
            connection.ClientId = "MyId";
            LastCall.On(connection).Repeat.Once();
            connection.Start();
            LastCall.On(connection).Repeat.Twice();
            connection.Stop();
            LastCall.On(connection).Repeat.Once();
            connection.Close();
            LastCall.On(connection).Repeat.Once();

            mocks.ReplayAll();

            SingleConnectionFactory scf = new SingleConnectionFactory(connectionFactory);
            scf.ClientId = "MyId";
            IConnection con1 = scf.CreateConnection();
            con1.Start();
            con1.Close(); // should be ignored
            IConnection con2 = scf.CreateConnection();
            con2.Start();
            con2.Close();   // should be ignored
            scf.Dispose();  // should trigger actual close

            mocks.VerifyAll();


        }

11. Example

Project: spring-net
Source File: SingleConnectionFactoryTests.cs
[Test]
        public void UsingConnectionFactoryAndExceptionListener()
        {
            IConnectionFactory connectionFactory = mocks.StrictMock<IConnectionFactory>();
            IConnection connection = mocks.StrictMock<IConnection>();


            IExceptionListener listener = new ChainedExceptionListener();
            Expect.Call(connectionFactory.CreateConnection()).Return(connection).Repeat.Once();
            connection.ExceptionListener += listener.OnException;
            LastCall.On(connection).IgnoreArguments();

            connection.Start();
            LastCall.On(connection).Repeat.Twice();
            connection.Stop();
            LastCall.On(connection).Repeat.Once();
            connection.Close();
            LastCall.On(connection).Repeat.Once();

            mocks.ReplayAll();
            
            SingleConnectionFactory scf = new SingleConnectionFactory(connectionFactory);
            scf.ExceptionListener = listener;
            IConnection con1 = scf.CreateConnection();

            //can't look at invocation list on event ...grrr.

            con1.Start();
            con1.Stop(); // should be ignored
            con1.Close(); // should be ignored
            IConnection con2 = scf.CreateConnection();
            con2.Start();
            con2.Stop();
            con2.Close();
            scf.Dispose();
                       
            mocks.VerifyAll();
        }

12. Example

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

13. Example

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

14. 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();
        }

15. 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();
        }

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: SingleConnectionFactoryTests.cs
[Test]
        public void CachingConnectionFactory()
        {
            IConnectionFactory conne/n ..... /n //View Source file for more details /n }

18. Example

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