Java Code Examples for javax.jms.QueueConnection#stop()

The following examples show how to use javax.jms.QueueConnection#stop() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SingleConnectionFactoryTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void testWithQueueConnection() throws JMSException {
	Connection con = mock(QueueConnection.class);

	SingleConnectionFactory scf = new SingleConnectionFactory(con);
	QueueConnection con1 = scf.createQueueConnection();
	con1.start();
	con1.stop();
	con1.close();
	QueueConnection con2 = scf.createQueueConnection();
	con2.start();
	con2.stop();
	con2.close();
	scf.destroy();  // should trigger actual close

	verify(con, times(2)).start();
	verify(con, times(2)).stop();
	verify(con).close();
	verifyNoMoreInteractions(con);
}
 
Example 2
Source File: SingleConnectionFactoryTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void testWithQueueConnection() throws JMSException {
	Connection con = mock(QueueConnection.class);

	SingleConnectionFactory scf = new SingleConnectionFactory(con);
	QueueConnection con1 = scf.createQueueConnection();
	con1.start();
	con1.stop();
	con1.close();
	QueueConnection con2 = scf.createQueueConnection();
	con2.start();
	con2.stop();
	con2.close();
	scf.destroy();  // should trigger actual close

	verify(con, times(2)).start();
	verify(con, times(2)).stop();
	verify(con).close();
	verifyNoMoreInteractions(con);
}
 
Example 3
Source File: SingleConnectionFactoryTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithQueueConnection() throws JMSException {
	Connection con = mock(QueueConnection.class);

	SingleConnectionFactory scf = new SingleConnectionFactory(con);
	QueueConnection con1 = scf.createQueueConnection();
	con1.start();
	con1.stop();
	con1.close();
	QueueConnection con2 = scf.createQueueConnection();
	con2.start();
	con2.stop();
	con2.close();
	scf.destroy();  // should trigger actual close

	verify(con, times(2)).start();
	verify(con, times(2)).stop();
	verify(con).close();
	verifyNoMoreInteractions(con);
}
 
Example 4
Source File: AndesJMSConsumer.java    From product-ei with Apache License 2.0 4 votes vote down vote up
public void stopClientSync(){
    if (null != connection && null != session && null != receiver) {
        try {
            log.info("Closing Consumer");
            if (ExchangeType.TOPIC == consumerConfig.getExchangeType()) {
                if (null != receiver) {
                    TopicSubscriber topicSubscriber = (TopicSubscriber) receiver;
                    topicSubscriber.close();
                }

                if (null != session) {
                    TopicSession topicSession = (TopicSession) session;
                    topicSession.close();
                }

                if (null != connection) {
                    TopicConnection topicConnection = (TopicConnection) connection;
                    topicConnection.close();
                }
            } else if (ExchangeType.QUEUE == consumerConfig.getExchangeType()) {
                if (null != receiver) {
                    QueueReceiver queueReceiver = (QueueReceiver) receiver;
                    queueReceiver.close();
                }

                if (null != session) {
                    QueueSession queueSession = (QueueSession) session;
                    queueSession.close();
                }

                if (null != connection) {
                    QueueConnection queueConnection = (QueueConnection) connection;
                    queueConnection.stop();
                    queueConnection.close();
                }
            }

            receiver = null;
            session = null;
            connection = null;

            log.info("Consumer Closed");

        } catch (JMSException e) {
            log.error("Error in stopping client.", e);
            throw new RuntimeException("Error in stopping client.", e);
        }
    }
}