use of org.springframework.jms.support.QosSettings in project spring-framework by spring-projects.
the class JmsListenerContainerFactoryTests method assertDefaultJcaConfig.
private void assertDefaultJcaConfig(JmsMessageEndpointManager container) {
assertThat(container.getMessageConverter()).isEqualTo(this.messageConverter);
assertThat(container.getDestinationResolver()).isEqualTo(this.destinationResolver);
JmsActivationSpecConfig config = container.getActivationSpecConfig();
assertThat(config).isNotNull();
assertThat(config.getAcknowledgeMode()).isEqualTo(Session.DUPS_OK_ACKNOWLEDGE);
assertThat(config.isPubSubDomain()).isTrue();
assertThat(container.getReplyQosSettings()).isEqualTo(new QosSettings(1, 7, 5000));
assertThat(config.isSubscriptionDurable()).isTrue();
assertThat(config.getClientId()).isEqualTo("client-1234");
}
use of org.springframework.jms.support.QosSettings in project spring-framework by spring-projects.
the class JmsListenerContainerFactoryTests method setDefaultJcaConfig.
private void setDefaultJcaConfig(DefaultJcaListenerContainerFactory factory) {
factory.setDestinationResolver(this.destinationResolver);
factory.setTransactionManager(this.transactionManager);
factory.setMessageConverter(this.messageConverter);
factory.setAcknowledgeMode(Session.DUPS_OK_ACKNOWLEDGE);
factory.setPubSubDomain(true);
factory.setReplyQosSettings(new QosSettings(1, 7, 5000));
factory.setSubscriptionDurable(true);
factory.setClientId("client-1234");
}
use of org.springframework.jms.support.QosSettings in project spring-framework by spring-projects.
the class MethodJmsListenerEndpoint method createMessageListener.
@Override
protected MessagingMessageListenerAdapter createMessageListener(MessageListenerContainer container) {
Assert.state(this.messageHandlerMethodFactory != null, "Could not create message listener - MessageHandlerMethodFactory not set");
MessagingMessageListenerAdapter messageListener = createMessageListenerInstance();
Object bean = getBean();
Method method = getMethod();
Assert.state(bean != null && method != null, "No bean+method set on endpoint");
InvocableHandlerMethod invocableHandlerMethod = this.messageHandlerMethodFactory.createInvocableHandlerMethod(bean, method);
messageListener.setHandlerMethod(invocableHandlerMethod);
String responseDestination = getDefaultResponseDestination();
if (StringUtils.hasText(responseDestination)) {
if (container.isReplyPubSubDomain()) {
messageListener.setDefaultResponseTopicName(responseDestination);
} else {
messageListener.setDefaultResponseQueueName(responseDestination);
}
}
QosSettings responseQosSettings = container.getReplyQosSettings();
if (responseQosSettings != null) {
messageListener.setResponseQosSettings(responseQosSettings);
}
MessageConverter messageConverter = container.getMessageConverter();
if (messageConverter != null) {
messageListener.setMessageConverter(messageConverter);
}
DestinationResolver destinationResolver = container.getDestinationResolver();
if (destinationResolver != null) {
messageListener.setDestinationResolver(destinationResolver);
}
return messageListener;
}
use of org.springframework.jms.support.QosSettings in project spring-framework by spring-projects.
the class MessagingMessageListenerAdapterTests method replyWithFullQoS.
@Test
public void replyWithFullQoS() 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(DeliveryMode.NON_PERSISTENT, 6, 6000);
listener.setResponseQosSettings(settings);
listener.onMessage(mock(jakarta.jms.Message.class), session);
verify(session).createQueue("queueOut");
verify(session).createTextMessage("Response");
verify(messageProducer).send(responseMessage, DeliveryMode.NON_PERSISTENT, 6, 6000);
verify(messageProducer).close();
}
Aggregations