Search in sources :

Example 1 with QosSettings

use of org.springframework.jms.support.QosSettings in project spring-framework by spring-projects.

the class JmsListenerContainerFactoryTests method assertDefaultJmsConfig.

private void assertDefaultJmsConfig(AbstractMessageListenerContainer container) {
    assertThat(container.getConnectionFactory()).isEqualTo(this.connectionFactory);
    assertThat(container.getDestinationResolver()).isEqualTo(this.destinationResolver);
    assertThat(container.getMessageConverter()).isEqualTo(this.messageConverter);
    assertThat(container.isSessionTransacted()).isTrue();
    assertThat(container.getSessionAcknowledgeMode()).isEqualTo(Session.DUPS_OK_ACKNOWLEDGE);
    assertThat(container.isPubSubDomain()).isTrue();
    assertThat(container.isReplyPubSubDomain()).isTrue();
    assertThat(container.getReplyQosSettings()).isEqualTo(new QosSettings(1, 7, 5000));
    assertThat(container.isSubscriptionDurable()).isTrue();
    assertThat(container.getClientId()).isEqualTo("client-1234");
    assertThat(container.isAutoStartup()).isFalse();
}
Also used : QosSettings(org.springframework.jms.support.QosSettings)

Example 2 with QosSettings

use of org.springframework.jms.support.QosSettings in project spring-framework by spring-projects.

the class JmsListenerContainerFactoryTests method setDefaultJmsConfig.

private void setDefaultJmsConfig(AbstractJmsListenerContainerFactory<?> factory) {
    factory.setConnectionFactory(this.connectionFactory);
    factory.setDestinationResolver(this.destinationResolver);
    factory.setMessageConverter(this.messageConverter);
    factory.setSessionTransacted(true);
    factory.setSessionAcknowledgeMode(Session.DUPS_OK_ACKNOWLEDGE);
    factory.setPubSubDomain(true);
    factory.setReplyPubSubDomain(true);
    factory.setReplyQosSettings(new QosSettings(1, 7, 5000));
    factory.setSubscriptionDurable(true);
    factory.setClientId("client-1234");
    factory.setAutoStartup(false);
}
Also used : QosSettings(org.springframework.jms.support.QosSettings)

Example 3 with QosSettings

use of org.springframework.jms.support.QosSettings in project spring-framework by spring-projects.

the class MessagingMessageListenerAdapterTests method replyWithCustomTimeToLive.

@Test
public void replyWithCustomTimeToLive() throws JMSException {
    Session session = mock(Session.class);
    Queue replyDestination = mock(Queue.class);
    given(session.createQueue("queueOut")).willReturn(replyDestination);
    MessageProducer messageProducer = mock(MessageProducer.class);
    TextMessage responseMessage = mock(TextMessage.class);
    given(session.createTextMessage("Response")).willReturn(responseMessage);
    given(session.createProducer(replyDestination)).willReturn(messageProducer);
    MessagingMessageListenerAdapter listener = getPayloadInstance("Response", "replyPayloadToQueue", Message.class);
    QosSettings settings = new QosSettings();
    settings.setTimeToLive(6000);
    listener.setResponseQosSettings(settings);
    listener.onMessage(mock(jakarta.jms.Message.class), session);
    verify(session).createQueue("queueOut");
    verify(session).createTextMessage("Response");
    verify(messageProducer).send(responseMessage, jakarta.jms.Message.DEFAULT_DELIVERY_MODE, jakarta.jms.Message.DEFAULT_PRIORITY, 6000);
    verify(messageProducer).close();
}
Also used : StubTextMessage(org.springframework.jms.StubTextMessage) Message(org.springframework.messaging.Message) TextMessage(jakarta.jms.TextMessage) QosSettings(org.springframework.jms.support.QosSettings) MessageProducer(jakarta.jms.MessageProducer) Queue(jakarta.jms.Queue) StubTextMessage(org.springframework.jms.StubTextMessage) TextMessage(jakarta.jms.TextMessage) Session(jakarta.jms.Session) Test(org.junit.jupiter.api.Test)

Example 4 with QosSettings

use of org.springframework.jms.support.QosSettings in project spring-framework by spring-projects.

the class JmsMessageEndpointManagerTests method customReplyQosSettings.

@Test
public void customReplyQosSettings() {
    JmsMessageEndpointManager endpoint = new JmsMessageEndpointManager();
    JmsActivationSpecConfig config = new JmsActivationSpecConfig();
    QosSettings settings = new QosSettings(1, 3, 5);
    config.setReplyQosSettings(settings);
    endpoint.setActivationSpecConfig(config);
    assertThat(endpoint.getReplyQosSettings()).isNotNull();
    assertThat(endpoint.getReplyQosSettings().getDeliveryMode()).isEqualTo(1);
    assertThat(endpoint.getReplyQosSettings().getPriority()).isEqualTo(3);
    assertThat(endpoint.getReplyQosSettings().getTimeToLive()).isEqualTo(5);
}
Also used : QosSettings(org.springframework.jms.support.QosSettings) Test(org.junit.jupiter.api.Test)

Example 5 with QosSettings

use of org.springframework.jms.support.QosSettings in project spring-framework by spring-projects.

the class MethodJmsListenerEndpointTests method processAndReplyWithCustomReplyQosSettings.

@Test
void processAndReplyWithCustomReplyQosSettings() throws JMSException {
    String methodName = "processAndReplyWithSendTo";
    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
    QosSettings replyQosSettings = new QosSettings(1, 6, 6000);
    container.setReplyQosSettings(replyQosSettings);
    MessagingMessageListenerAdapter listener = createInstance(this.factory, getListenerMethod(methodName, String.class), container);
    processAndReplyWithSendTo(listener, "replyDestination", false, replyQosSettings);
    assertListenerMethodInvocation(this.sample, methodName);
}
Also used : MessagingMessageListenerAdapter(org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter) QosSettings(org.springframework.jms.support.QosSettings) SimpleMessageListenerContainer(org.springframework.jms.listener.SimpleMessageListenerContainer) Test(org.junit.jupiter.api.Test)

Aggregations

QosSettings (org.springframework.jms.support.QosSettings)9 Test (org.junit.jupiter.api.Test)4 MessageProducer (jakarta.jms.MessageProducer)2 Queue (jakarta.jms.Queue)2 Session (jakarta.jms.Session)2 TextMessage (jakarta.jms.TextMessage)2 StubTextMessage (org.springframework.jms.StubTextMessage)2 MessagingMessageListenerAdapter (org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter)2 Message (org.springframework.messaging.Message)2 Method (java.lang.reflect.Method)1 SimpleMessageListenerContainer (org.springframework.jms.listener.SimpleMessageListenerContainer)1 JmsActivationSpecConfig (org.springframework.jms.listener.endpoint.JmsActivationSpecConfig)1 MessageConverter (org.springframework.jms.support.converter.MessageConverter)1 DestinationResolver (org.springframework.jms.support.destination.DestinationResolver)1 InvocableHandlerMethod (org.springframework.messaging.handler.invocation.InvocableHandlerMethod)1