This repository was archived by the owner on Feb 21, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +41
-2
lines changed
src/main/java/org/springframework Expand file tree Collapse file tree 4 files changed +41
-2
lines changed Original file line number Diff line number Diff line change 2121 <artifactId >spring-boot-autoconfigure</artifactId >
2222 <scope >provided</scope >
2323 </dependency >
24+ <dependency >
25+ <groupId >org.springframework.boot</groupId >
26+ <artifactId >spring-boot-configuration-processor</artifactId >
27+ <optional >true</optional >
28+ </dependency >
2429 <dependency >
2530 <groupId >org.springframework.amqp</groupId >
2631 <artifactId >spring-rabbit</artifactId >
Original file line number Diff line number Diff line change 66import java .lang .reflect .Proxy ;
77import org .springframework .amqp .core .AbstractDeclarable ;
88import org .springframework .amqp .core .Declarable ;
9+ import org .springframework .amqp .rabbit .connection .ConnectionFactory ;
910import org .springframework .context .ApplicationContext ;
1011import org .springframework .context .ApplicationContextAware ;
12+ import org .springframework .util .Assert ;
1113import org .springframework .util .StringUtils ;
1214
1315/**
@@ -27,6 +29,20 @@ public final class MultiRabbitListenerAnnotationBeanPostProcessor
2729
2830 private ApplicationContext applicationContext ;
2931
32+ /**
33+ * Injecting multiRabbitConnectionFactory bean to make sure
34+ * {@link org.springframework.boot.autoconfigure.amqp.MultiRabbitAutoConfiguration} is completely initialized
35+ * before start the post processor processAmqpListener.
36+ *
37+ * @param multiRabbitConnectionFactory Routing connection factory populated with the connection factories provided
38+ * from {@link org.springframework.boot.autoconfigure.amqp.MultiRabbitAutoConfiguration}.
39+ */
40+ public MultiRabbitListenerAnnotationBeanPostProcessor (
41+ final ConnectionFactory multiRabbitConnectionFactory ) {
42+ super ();
43+ Assert .state (multiRabbitConnectionFactory != null , "multiRabbitConnectionFactory must be available" );
44+ }
45+
3046 @ Override
3147 protected void processAmqpListener (final RabbitListener rabbitListener ,
3248 final Method method ,
Original file line number Diff line number Diff line change 1+ package org .springframework .amqp .rabbit .annotation ;
2+
3+ import org .springframework .context .annotation .DeferredImportSelector ;
4+ import org .springframework .core .annotation .Order ;
5+ import org .springframework .core .type .AnnotationMetadata ;
6+
7+ /**
8+ * A {@link DeferredImportSelector} implementation with the lowest order to import a
9+ * {@link MultiRabbitBootstrapConfiguration} as late as possible.
10+ */
11+ @ Order
12+ public class MultiRabbitListenerConfigurationSelector implements DeferredImportSelector {
13+
14+ @ Override
15+ public String [] selectImports (final AnnotationMetadata importingClassMetadata ) {
16+ return new String [] {MultiRabbitBootstrapConfiguration .class .getName ()};
17+ }
18+ }
Original file line number Diff line number Diff line change 33import com .rabbitmq .client .Channel ;
44import org .slf4j .Logger ;
55import org .slf4j .LoggerFactory ;
6- import org .springframework .amqp .rabbit .annotation .MultiRabbitBootstrapConfiguration ;
6+ import org .springframework .amqp .rabbit .annotation .MultiRabbitListenerConfigurationSelector ;
77import org .springframework .amqp .rabbit .config .AbstractRabbitListenerContainerFactory ;
88import org .springframework .amqp .rabbit .config .SimpleRabbitListenerContainerFactory ;
99import org .springframework .amqp .rabbit .connection .CachingConnectionFactory ;
3939@ Configuration
4040@ ConditionalOnClass ({RabbitTemplate .class , Channel .class })
4141@ EnableConfigurationProperties ({RabbitProperties .class , MultiRabbitProperties .class })
42- @ Import ({MultiRabbitBootstrapConfiguration .class , RabbitAutoConfiguration .class })
42+ @ Import ({MultiRabbitListenerConfigurationSelector .class , RabbitAutoConfiguration .class })
4343public class MultiRabbitAutoConfiguration {
4444
4545 private static final Logger LOGGER = LoggerFactory .getLogger (MultiRabbitAutoConfiguration .class );
You can’t perform that action at this time.
0 commit comments