Search in sources :

Example 6 with TopicConnection

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

the class SingleConnectionFactoryTests method testWithTopicConnection.

@Test
public void testWithTopicConnection() throws JMSException {
    Connection con = mock(TopicConnection.class);
    SingleConnectionFactory scf = new SingleConnectionFactory(con);
    TopicConnection con1 = scf.createTopicConnection();
    con1.start();
    con1.stop();
    con1.close();
    TopicConnection con2 = scf.createTopicConnection();
    con2.start();
    con2.stop();
    con2.close();
    // should trigger actual close
    scf.destroy();
    verify(con, times(2)).start();
    verify(con, times(2)).stop();
    verify(con).close();
    verifyNoMoreInteractions(con);
}
Also used : QueueConnection(jakarta.jms.QueueConnection) TopicConnection(jakarta.jms.TopicConnection) Connection(jakarta.jms.Connection) TopicConnection(jakarta.jms.TopicConnection) Test(org.junit.jupiter.api.Test)

Example 7 with TopicConnection

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

the class TransactionAwareConnectionFactoryProxy method createTopicConnection.

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

Aggregations

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