Search in sources :

Example 6 with QueueConnection

use of jakarta.jms.QueueConnection in project spring-framework by spring-projects.

the class SingleConnectionFactoryTests method testWithQueueConnectionFactoryAndJms102Usage.

@Test
public void testWithQueueConnectionFactoryAndJms102Usage() throws JMSException {
    QueueConnectionFactory cf = mock(QueueConnectionFactory.class);
    QueueConnection con = mock(QueueConnection.class);
    given(cf.createQueueConnection()).willReturn(con);
    SingleConnectionFactory scf = new SingleConnectionFactory(cf);
    Connection con1 = scf.createQueueConnection();
    Connection con2 = scf.createQueueConnection();
    con1.start();
    con2.start();
    con1.close();
    con2.close();
    // should trigger actual close
    scf.destroy();
    verify(con).start();
    verify(con).stop();
    verify(con).close();
    verifyNoMoreInteractions(con);
}
Also used : QueueConnection(jakarta.jms.QueueConnection) QueueConnectionFactory(jakarta.jms.QueueConnectionFactory) QueueConnection(jakarta.jms.QueueConnection) TopicConnection(jakarta.jms.TopicConnection) Connection(jakarta.jms.Connection) Test(org.junit.jupiter.api.Test)

Example 7 with QueueConnection

use of jakarta.jms.QueueConnection in project spring-framework by spring-projects.

the class TransactionAwareConnectionFactoryProxy method createQueueConnection.

@Override
public QueueConnection createQueueConnection(String username, String password) throws JMSException {
    ConnectionFactory target = getTargetConnectionFactory();
    if (!(target instanceof QueueConnectionFactory)) {
        throw new jakarta.jms.IllegalStateException("'targetConnectionFactory' is no QueueConnectionFactory");
    }
    QueueConnection targetConnection = ((QueueConnectionFactory) target).createQueueConnection(username, password);
    return (QueueConnection) getTransactionAwareConnectionProxy(targetConnection);
}
Also used : TopicConnectionFactory(jakarta.jms.TopicConnectionFactory) ConnectionFactory(jakarta.jms.ConnectionFactory) QueueConnectionFactory(jakarta.jms.QueueConnectionFactory) QueueConnection(jakarta.jms.QueueConnection) QueueConnectionFactory(jakarta.jms.QueueConnectionFactory)

Aggregations

QueueConnection (jakarta.jms.QueueConnection)7 Connection (jakarta.jms.Connection)5 QueueConnectionFactory (jakarta.jms.QueueConnectionFactory)5 TopicConnection (jakarta.jms.TopicConnection)5 Test (org.junit.jupiter.api.Test)4 ConnectionFactory (jakarta.jms.ConnectionFactory)2 TopicConnectionFactory (jakarta.jms.TopicConnectionFactory)2 QueueSession (jakarta.jms.QueueSession)1 Session (jakarta.jms.Session)1 TopicSession (jakarta.jms.TopicSession)1