Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
1f00c27c
Commit
1f00c27c
authored
Feb 14, 2021
by
Eddú Meléndez
Committed by
Stephane Nicoll
Feb 15, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support to auto-configure javax.jms.ExceptionListener
See gh-25278
parent
193fdd7b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
4 deletions
+46
-4
DefaultJmsListenerContainerFactoryConfigurer.java
...ure/jms/DefaultJmsListenerContainerFactoryConfigurer.java
+16
-1
JmsAnnotationDrivenConfiguration.java
...t/autoconfigure/jms/JmsAnnotationDrivenConfiguration.java
+8
-2
JmsAutoConfigurationTests.java
...ork/boot/autoconfigure/jms/JmsAutoConfigurationTests.java
+22
-1
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/DefaultJmsListenerContainerFactoryConfigurer.java
View file @
1f00c27c
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
21
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.
...
...
@@ -19,6 +19,7 @@ package org.springframework.boot.autoconfigure.jms;
import
java.time.Duration
;
import
javax.jms.ConnectionFactory
;
import
javax.jms.ExceptionListener
;
import
org.springframework.jms.config.DefaultJmsListenerContainerFactory
;
import
org.springframework.jms.support.converter.MessageConverter
;
...
...
@@ -30,6 +31,7 @@ import org.springframework.util.Assert;
* Configure {@link DefaultJmsListenerContainerFactory} with sensible defaults.
*
* @author Stephane Nicoll
* @author Eddú Meléndez
* @since 1.3.3
*/
public
final
class
DefaultJmsListenerContainerFactoryConfigurer
{
...
...
@@ -42,6 +44,8 @@ public final class DefaultJmsListenerContainerFactoryConfigurer {
private
JmsProperties
jmsProperties
;
private
ExceptionListener
exceptionListener
;
/**
* Set the {@link DestinationResolver} to use or {@code null} if no destination
* resolver should be associated with the factory by default.
...
...
@@ -77,6 +81,14 @@ public final class DefaultJmsListenerContainerFactoryConfigurer {
this
.
jmsProperties
=
jmsProperties
;
}
/**
* Set the {@link ExceptionListener}.
* @param exceptionListener the {@link ExceptionListener}
*/
void
setExceptionListener
(
ExceptionListener
exceptionListener
)
{
this
.
exceptionListener
=
exceptionListener
;
}
/**
* Configure the specified jms listener container factory. The factory can be further
* tuned and default settings can be overridden.
...
...
@@ -113,6 +125,9 @@ public final class DefaultJmsListenerContainerFactoryConfigurer {
if
(
receiveTimeout
!=
null
)
{
factory
.
setReceiveTimeout
(
receiveTimeout
.
toMillis
());
}
if
(
this
.
exceptionListener
!=
null
)
{
factory
.
setExceptionListener
(
this
.
exceptionListener
);
}
}
}
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/JmsAnnotationDrivenConfiguration.java
View file @
1f00c27c
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
21
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.
...
...
@@ -17,6 +17,7 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
jms
;
import
javax.jms.ConnectionFactory
;
import
javax.jms.ExceptionListener
;
import
org.springframework.beans.factory.ObjectProvider
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
...
...
@@ -38,6 +39,7 @@ import org.springframework.transaction.jta.JtaTransactionManager;
*
* @author Phillip Webb
* @author Stephane Nicoll
* @author Eddú Meléndez
*/
@Configuration
(
proxyBeanMethods
=
false
)
@ConditionalOnClass
(
EnableJms
.
class
)
...
...
@@ -49,14 +51,17 @@ class JmsAnnotationDrivenConfiguration {
private
final
ObjectProvider
<
MessageConverter
>
messageConverter
;
private
final
ObjectProvider
<
ExceptionListener
>
exceptionListener
;
private
final
JmsProperties
properties
;
JmsAnnotationDrivenConfiguration
(
ObjectProvider
<
DestinationResolver
>
destinationResolver
,
ObjectProvider
<
JtaTransactionManager
>
transactionManager
,
ObjectProvider
<
MessageConverter
>
messageConverter
,
JmsProperties
properties
)
{
ObjectProvider
<
ExceptionListener
>
exceptionListener
,
JmsProperties
properties
)
{
this
.
destinationResolver
=
destinationResolver
;
this
.
transactionManager
=
transactionManager
;
this
.
messageConverter
=
messageConverter
;
this
.
exceptionListener
=
exceptionListener
;
this
.
properties
=
properties
;
}
...
...
@@ -67,6 +72,7 @@ class JmsAnnotationDrivenConfiguration {
configurer
.
setDestinationResolver
(
this
.
destinationResolver
.
getIfUnique
());
configurer
.
setTransactionManager
(
this
.
transactionManager
.
getIfUnique
());
configurer
.
setMessageConverter
(
this
.
messageConverter
.
getIfUnique
());
configurer
.
setExceptionListener
(
this
.
exceptionListener
.
getIfUnique
());
configurer
.
setJmsProperties
(
this
.
properties
);
return
configurer
;
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/JmsAutoConfigurationTests.java
View file @
1f00c27c
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
21
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.
...
...
@@ -17,6 +17,7 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
jms
;
import
javax.jms.ConnectionFactory
;
import
javax.jms.ExceptionListener
;
import
javax.jms.Session
;
import
org.apache.activemq.ActiveMQConnectionFactory
;
...
...
@@ -56,6 +57,7 @@ import static org.mockito.Mockito.mock;
* @author Greg Turnquist
* @author Stephane Nicoll
* @author Aurélien Leboulanger
* @author Eddú Meléndez
*/
class
JmsAutoConfigurationTests
{
...
...
@@ -393,6 +395,15 @@ class JmsAutoConfigurationTests {
.
hasBean
(
JmsListenerConfigUtils
.
JMS_LISTENER_ENDPOINT_REGISTRY_BEAN_NAME
));
}
@Test
void
testDefaultContainerFactoryWithExceptionListener
()
{
this
.
contextRunner
.
withUserConfiguration
(
TestConfiguration11
.
class
,
EnableJmsConfiguration
.
class
)
.
run
((
context
)
->
{
DefaultMessageListenerContainer
container
=
getContainer
(
context
,
"jmsListenerContainerFactory"
);
assertThat
(
container
.
getExceptionListener
()).
isSameAs
(
context
.
getBean
(
"exceptionListener"
));
});
}
@Configuration
(
proxyBeanMethods
=
false
)
static
class
TestConfiguration
{
...
...
@@ -548,6 +559,16 @@ class JmsAutoConfigurationTests {
}
@Configuration
(
proxyBeanMethods
=
false
)
static
class
TestConfiguration11
{
@Bean
ExceptionListener
exceptionListener
()
{
return
mock
(
ExceptionListener
.
class
);
}
}
@Configuration
(
proxyBeanMethods
=
false
)
@EnableJms
static
class
EnableJmsConfiguration
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment