diff --git a/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/messaging/jms.adoc b/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/messaging/jms.adoc index 2e64c157108..7253d001b4b 100644 --- a/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/messaging/jms.adoc +++ b/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/messaging/jms.adoc @@ -191,3 +191,8 @@ NOTE: In the example above, the customization uses javadoc:org.springframework.b Then you can use the factory in any javadoc:org.springframework.jms.annotation.JmsListener[format=annotation]-annotated method as follows: include-code::custom/MyBean[] + +Analogous to `DefaultJmsListenerContainerFactoryConfigurer`, Spring Boot also provides a javadoc:org.springframework.boot.jms.autoconfigure.SimpleJmsListenerContainerFactoryConfigurer[] that you can use to initialize a javadoc:org.springframework.jms.config.SimpleJmsListenerContainerFactory[] and apply the related settings that auto-configuration provides. + +TIP: In contrast to javadoc:org.springframework.jms.listener.DefaultMessageListenerContainer[] that uses a pull-based mechanism (polling) to process messages, javadoc:org.springframework.jms.listener.SimpleMessageListenerContainer[] uses a push-based mechanism that's very close to the spirit of the standalone JMS specification. +To learn more about the differences between the two listener containers, consult their respective javadocs and {url-spring-framework-docs}/integration/jms/using.html#jms-mdp[Spring Framework reference documentation]. diff --git a/module/spring-boot-jms/src/main/java/org/springframework/boot/jms/autoconfigure/AbstractJmsListenerContainerFactoryConfigurer.java b/module/spring-boot-jms/src/main/java/org/springframework/boot/jms/autoconfigure/AbstractJmsListenerContainerFactoryConfigurer.java new file mode 100644 index 00000000000..b99fa99326c --- /dev/null +++ b/module/spring-boot-jms/src/main/java/org/springframework/boot/jms/autoconfigure/AbstractJmsListenerContainerFactoryConfigurer.java @@ -0,0 +1,141 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.jms.autoconfigure; + +import io.micrometer.observation.ObservationRegistry; +import jakarta.jms.ConnectionFactory; +import jakarta.jms.ExceptionListener; +import org.jspecify.annotations.Nullable; + +import org.springframework.boot.context.properties.PropertyMapper; +import org.springframework.boot.jms.autoconfigure.JmsProperties.Listener.Session; +import org.springframework.jms.config.AbstractJmsListenerContainerFactory; +import org.springframework.jms.config.JmsListenerContainerFactory; +import org.springframework.jms.support.converter.MessageConverter; +import org.springframework.jms.support.destination.DestinationResolver; +import org.springframework.util.Assert; + +/** + * Configure common {@link JmsListenerContainerFactory} settings with sensible defaults. + *
+ * This includes: + *
+ * As such, concurrency-related configuration properties from the {@code spring.jms} + * namespace are not taken into account by this implementation. + *
+ * Can be injected into application code and used to define a custom
+ * {@code SimpleJmsListenerContainerFactory} whose configuration is based upon that
+ * produced by auto-configuration.
+ *
+ * @author Vedran Pavic
+ * @author Stephane Nicoll
+ * @since 4.0.0
+ * @see DefaultJmsListenerContainerFactoryConfigurer
+ */
+public final class SimpleJmsListenerContainerFactoryConfigurer
+ extends AbstractJmsListenerContainerFactoryConfigurer