Search in sources :

Example 1 with ConnectionFactory

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

the class MyJmsConfiguration method myFactory.

@Bean
public DefaultJmsListenerContainerFactory myFactory(DefaultJmsListenerContainerFactoryConfigurer configurer) {
    DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
    ConnectionFactory connectionFactory = getCustomConnectionFactory();
    configurer.configure(factory, connectionFactory);
    factory.setMessageConverter(new MyMessageConverter());
    return factory;
}
Also used : DefaultJmsListenerContainerFactory(org.springframework.jms.config.DefaultJmsListenerContainerFactory) ConnectionFactory(jakarta.jms.ConnectionFactory) Bean(org.springframework.context.annotation.Bean)

Example 2 with ConnectionFactory

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

the class ArtemisAutoConfigurationTests method nativeConnectionFactory.

@Test
void nativeConnectionFactory() {
    this.contextRunner.withUserConfiguration(EmptyConfiguration.class).withPropertyValues("spring.artemis.mode:native").run((context) -> {
        JmsTemplate jmsTemplate = context.getBean(JmsTemplate.class);
        ConnectionFactory connectionFactory = getConnectionFactory(context);
        assertThat(connectionFactory).isEqualTo(jmsTemplate.getConnectionFactory());
        ActiveMQConnectionFactory activeMQConnectionFactory = getActiveMQConnectionFactory(connectionFactory);
        assertNettyConnectionFactory(activeMQConnectionFactory, "localhost", 61616);
        assertThat(activeMQConnectionFactory.getUser()).isNull();
        assertThat(activeMQConnectionFactory.getPassword()).isNull();
    });
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) CachingConnectionFactory(org.springframework.jms.connection.CachingConnectionFactory) ConnectionFactory(jakarta.jms.ConnectionFactory) JmsTemplate(org.springframework.jms.core.JmsTemplate) Test(org.junit.jupiter.api.Test)

Example 3 with ConnectionFactory

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

the class JndiConnectionFactoryAutoConfigurationTests method detectWithJmsXAConnectionFactory.

@Test
void detectWithJmsXAConnectionFactory() {
    ConnectionFactory connectionFactory = configureConnectionFactory("java:/JmsXA");
    this.contextRunner.run(assertConnectionFactory(connectionFactory));
}
Also used : ConnectionFactory(jakarta.jms.ConnectionFactory) Test(org.junit.jupiter.api.Test)

Example 4 with ConnectionFactory

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

the class JndiConnectionFactoryAutoConfigurationTests method configureConnectionFactory.

private ConnectionFactory configureConnectionFactory(String name) {
    ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
    TestableInitialContextFactory.bind(name, connectionFactory);
    return connectionFactory;
}
Also used : ConnectionFactory(jakarta.jms.ConnectionFactory)

Example 5 with ConnectionFactory

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

the class JndiConnectionFactoryAutoConfigurationTests method jndiNamePropertySetWithResourceRef.

@Test
void jndiNamePropertySetWithResourceRef() {
    ConnectionFactory connectionFactory = configureConnectionFactory("java:comp/env/myCF");
    this.contextRunner.withPropertyValues("spring.jms.jndi-name=myCF").run(assertConnectionFactory(connectionFactory));
}
Also used : ConnectionFactory(jakarta.jms.ConnectionFactory) Test(org.junit.jupiter.api.Test)

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