Search in sources :

Example 11 with ConnectionFactory

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

the class SingleConnectionFactory method obtainTargetConnectionFactory.

private ConnectionFactory obtainTargetConnectionFactory() {
    ConnectionFactory target = getTargetConnectionFactory();
    Assert.state(target != null, "'targetConnectionFactory' is required");
    return target;
}
Also used : TopicConnectionFactory(jakarta.jms.TopicConnectionFactory) ConnectionFactory(jakarta.jms.ConnectionFactory) QueueConnectionFactory(jakarta.jms.QueueConnectionFactory)

Example 12 with ConnectionFactory

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

the class JmsAccessor method obtainConnectionFactory.

/**
 * Obtain the ConnectionFactory for actual use.
 * @return the ConnectionFactory (never {@code null})
 * @throws IllegalStateException in case of no ConnectionFactory set
 * @since 5.0
 */
protected final ConnectionFactory obtainConnectionFactory() {
    ConnectionFactory connectionFactory = getConnectionFactory();
    Assert.state(connectionFactory != null, "No ConnectionFactory set");
    return connectionFactory;
}
Also used : ConnectionFactory(jakarta.jms.ConnectionFactory)

Example 13 with ConnectionFactory

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

the class TransactionAwareConnectionFactoryProxy method getTargetConnectionFactory.

/**
 * Return the target ConnectionFactory that this ConnectionFactory should delegate to.
 */
protected ConnectionFactory getTargetConnectionFactory() {
    ConnectionFactory target = this.targetConnectionFactory;
    Assert.state(target != null, "'targetConnectionFactory' is required");
    return target;
}
Also used : TopicConnectionFactory(jakarta.jms.TopicConnectionFactory) ConnectionFactory(jakarta.jms.ConnectionFactory) QueueConnectionFactory(jakarta.jms.QueueConnectionFactory)

Example 14 with ConnectionFactory

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

the class TransactionAwareConnectionFactoryProxy method createQueueConnection.

@Override
public QueueConnection createQueueConnection() throws JMSException {
    ConnectionFactory target = getTargetConnectionFactory();
    if (!(target instanceof QueueConnectionFactory)) {
        throw new jakarta.jms.IllegalStateException("'targetConnectionFactory' is no QueueConnectionFactory");
    }
    QueueConnection targetConnection = ((QueueConnectionFactory) target).createQueueConnection();
    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)

Example 15 with ConnectionFactory

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

the class TransactionAwareConnectionFactoryProxy method createTopicConnection.

@Override
public TopicConnection createTopicConnection() throws JMSException {
    ConnectionFactory target = getTargetConnectionFactory();
    if (!(target instanceof TopicConnectionFactory)) {
        throw new jakarta.jms.IllegalStateException("'targetConnectionFactory' is no TopicConnectionFactory");
    }
    TopicConnection targetConnection = ((TopicConnectionFactory) target).createTopicConnection();
    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

ConnectionFactory (jakarta.jms.ConnectionFactory)60 Test (org.junit.jupiter.api.Test)42 Connection (jakarta.jms.Connection)32 JMSException (jakarta.jms.JMSException)20 Session (jakarta.jms.Session)19 Message (jakarta.jms.Message)15 QueueConnectionFactory (jakarta.jms.QueueConnectionFactory)15 TopicConnectionFactory (jakarta.jms.TopicConnectionFactory)15 JmsTemplate (org.springframework.jms.core.JmsTemplate)11 QueueConnection (jakarta.jms.QueueConnection)10 TopicConnection (jakarta.jms.TopicConnection)10 StubQueue (org.springframework.jms.StubQueue)10 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)9 BDDMockito.given (org.mockito.BDDMockito.given)9 Mockito.mock (org.mockito.Mockito.mock)9 Mockito.verify (org.mockito.Mockito.verify)9 TransactionStatus (org.springframework.transaction.TransactionStatus)9 DefaultTransactionDefinition (org.springframework.transaction.support.DefaultTransactionDefinition)9 Destination (jakarta.jms.Destination)8 MessageProducer (jakarta.jms.MessageProducer)8