diff --git a/spring-integration-jms/src/main/java/org/springframework/integration/jms/AbstractJmsChannel.java b/spring-integration-jms/src/main/java/org/springframework/integration/jms/AbstractJmsChannel.java
index 4efc99655c..67b2741aae 100644
--- a/spring-integration-jms/src/main/java/org/springframework/integration/jms/AbstractJmsChannel.java
+++ b/spring-integration-jms/src/main/java/org/springframework/integration/jms/AbstractJmsChannel.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2024 the original author or authors.
+ * Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,9 +23,15 @@ import org.springframework.messaging.Message;
import org.springframework.util.Assert;
/**
+ * A base {@link AbstractMessageChannel} implementation for JMS-backed message channels.
+ *
* @author Mark Fisher
* @author Gary Russell
+ *
* @since 2.0
+ *
+ * @see PollableJmsChannel
+ * @see SubscribableJmsChannel
*/
public abstract class AbstractJmsChannel extends AbstractMessageChannel {
diff --git a/spring-integration-jms/src/main/java/org/springframework/integration/jms/ChannelPublishingJmsMessageListener.java b/spring-integration-jms/src/main/java/org/springframework/integration/jms/ChannelPublishingJmsMessageListener.java
index cc3cfc0592..e7a209b9d5 100644
--- a/spring-integration-jms/src/main/java/org/springframework/integration/jms/ChannelPublishingJmsMessageListener.java
+++ b/spring-integration-jms/src/main/java/org/springframework/integration/jms/ChannelPublishingJmsMessageListener.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2024 the original author or authors.
+ * Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -406,8 +406,8 @@ public class ChannelPublishingJmsMessageListener
headers.put(IntegrationMessageHeaderAccessor.DELIVERY_ATTEMPT, new AtomicInteger());
}
requestMessage =
- (result instanceof Message>) ?
- this.messageBuilderFactory.fromMessage((Message>) result).copyHeaders(headers).build() :
+ result instanceof Message> message ?
+ this.messageBuilderFactory.fromMessage(message).copyHeaders(headers).build() :
this.messageBuilderFactory.withPayload(result).copyHeaders(headers).build();
}
catch (RuntimeException e) {
diff --git a/spring-integration-jms/src/main/java/org/springframework/integration/jms/DefaultJmsHeaderMapper.java b/spring-integration-jms/src/main/java/org/springframework/integration/jms/DefaultJmsHeaderMapper.java
index a31bb36b3d..97b85485e4 100644
--- a/spring-integration-jms/src/main/java/org/springframework/integration/jms/DefaultJmsHeaderMapper.java
+++ b/spring-integration-jms/src/main/java/org/springframework/integration/jms/DefaultJmsHeaderMapper.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2024 the original author or authors.
+ * Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -159,9 +159,9 @@ public class DefaultJmsHeaderMapper extends JmsHeaderMapper {
if (jmsCorrelationId instanceof Number) {
jmsCorrelationId = jmsCorrelationId.toString();
}
- if (jmsCorrelationId instanceof String) {
+ if (jmsCorrelationId instanceof String jmsCorrelationIdStr) {
try {
- jmsMessage.setJMSCorrelationID((String) jmsCorrelationId);
+ jmsMessage.setJMSCorrelationID(jmsCorrelationIdStr);
}
catch (Exception ex) {
LOGGER.info("Failed to set JMSCorrelationID, skipping", ex);
@@ -171,9 +171,9 @@ public class DefaultJmsHeaderMapper extends JmsHeaderMapper {
private void populateReplyToPropertyFromHeaders(MessageHeaders headers, jakarta.jms.Message jmsMessage) {
Object jmsReplyTo = headers.get(JmsHeaders.REPLY_TO);
- if (jmsReplyTo instanceof Destination) {
+ if (jmsReplyTo instanceof Destination destination) {
try {
- jmsMessage.setJMSReplyTo((Destination) jmsReplyTo);
+ jmsMessage.setJMSReplyTo(destination);
}
catch (Exception ex) {
LOGGER.info("Failed to set JMSReplyTo, skipping", ex);
@@ -183,9 +183,9 @@ public class DefaultJmsHeaderMapper extends JmsHeaderMapper {
private void populateTypePropertyFromHeaders(MessageHeaders headers, jakarta.jms.Message jmsMessage) {
Object jmsType = headers.get(JmsHeaders.TYPE);
- if (jmsType instanceof String) {
+ if (jmsType instanceof String jmsTypeStr) {
try {
- jmsMessage.setJMSType((String) jmsType);
+ jmsMessage.setJMSType(jmsTypeStr);
}
catch (Exception ex) {
LOGGER.info("Failed to set JMSType, skipping", ex);
diff --git a/spring-integration-jms/src/main/java/org/springframework/integration/jms/DynamicJmsTemplate.java b/spring-integration-jms/src/main/java/org/springframework/integration/jms/DynamicJmsTemplate.java
index 9560230f6f..6bed9bd79a 100644
--- a/spring-integration-jms/src/main/java/org/springframework/integration/jms/DynamicJmsTemplate.java
+++ b/spring-integration-jms/src/main/java/org/springframework/integration/jms/DynamicJmsTemplate.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2021 the original author or authors.
+ * Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,6 +24,15 @@ import org.springframework.jms.support.destination.JmsDestinationAccessor;
import org.springframework.util.Assert;
/**
+ * A {@code JmsTemplate} implementation used by {@link JmsSendingMessageHandler} for
+ * propagating QoS properties from the request message into the underlying {@code
+ * producer.send(message, getDeliveryMode(), getPriority(), getTimeToLive())} API.
+ * Propagation is only applied when {@code explicitQosEnabled} is true.
+ *
+ * Starting with version 5.0.8, a default value of the receive-timeout is -1 (no wait)
+ * for the {@link CachingConnectionFactory} and {@code cacheConsumers}, otherwise
+ * it is 1 second.
+ *
* @author Mark Fisher
* @author Artem Bilan
*
@@ -45,8 +54,8 @@ public class DynamicJmsTemplate extends JmsTemplate {
public void setConnectionFactory(ConnectionFactory connectionFactory) {
super.setConnectionFactory(connectionFactory);
if (!this.receiveTimeoutExplicitlySet) {
- if (connectionFactory instanceof CachingConnectionFactory &&
- ((CachingConnectionFactory) connectionFactory).isCacheConsumers()) {
+ if (connectionFactory instanceof CachingConnectionFactory cachingConnectionFactory &&
+ cachingConnectionFactory.isCacheConsumers()) {
super.setReceiveTimeout(JmsDestinationAccessor.RECEIVE_TIMEOUT_NO_WAIT);
}
else {
diff --git a/spring-integration-jms/src/main/java/org/springframework/integration/jms/JmsDestinationPollingSource.java b/spring-integration-jms/src/main/java/org/springframework/integration/jms/JmsDestinationPollingSource.java
index e4f4d49588..90559bc3e3 100644
--- a/spring-integration-jms/src/main/java/org/springframework/integration/jms/JmsDestinationPollingSource.java
+++ b/spring-integration-jms/src/main/java/org/springframework/integration/jms/JmsDestinationPollingSource.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2024 the original author or authors.
+ * Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -137,8 +137,8 @@ public class JmsDestinationPollingSource extends AbstractMessageSource