springboot-rabbitmq
2020-11-12 19:18:51 33 举报
spring boot rabbitMq
作者其他创作
大纲/内容
beanFactory.registerSingleton(Queue)
AbstractMessageListenerContainer#start
RabbitListenerEndpointRegistrar#registerEndpoint
msg
创建MessageListenerContainer并缓存在本地的map集合中
createListenerContainer
此处是遍历处理,返回的是队列名称的数组,说明一个方法可以监听多个队列。
集合集中之后统一注册
RabbitListenerAnnotationBeanPostProcessor#afterSingletonsInstantiated
channel
注解中的内容......
RabbitListenerEndPoint
rabbitmq broker
registerBeansForDeclaration
向spring注册bean---RabbitBootstrapConfiguration
beanFactory.registerSingleton(Binding)
RabbitAnnotationDrivenConfiguration.EnableRabbitConfiguration
amqpAdmin.initialize()
引入spring-rabbit jar@EnableRabbit.class
RabbitListenerAnnotationBeanPostProcessor#postProcessAfterInitialization
N
blocking queue
@Import(RabbitListenerConfigurationSelector.class)
RabbitListenerEndpointRegistry#registerListenerContainer
getConnectionListener().onCreate(this.connection)
由具体的工厂创建
创建交换机、队列、和绑定关系
declareExchangesdeclareQueuesdeclareBindings
注册监听
startImmediately控制是否启动
AbstractRabbitListenerContainerFactory#createListenerContainer
MessageListener
获取到标记@RabbitListener的方法
checkMismatchedQueues
RabbitListenerAnnotationBeanPostProcessor#resolveQueues
applicationContext.getBeansOfType(Exchange.class)applicationContext.getBeansOfType(Queue.class)applicationContext.getBeansOfType(Binding.class)
创建对应的bean交换机、队列、绑定关系
@ConditionalOnClass(EnableRabbit.class)
HandlerAdapter
MessageListenerContainer
createConnection
@EnableRabbit
connection
beanFactory.registerSingleton(Exchange)
实现了SmartInitializingSingleton当前bean初始化之后被调用区别于InitializingBean#afterPropertiesSet
组装RabbitListenerEndpoint
RabbitAdmin#initialize
RabbitListenerConfigurationSelector#selectImports
....
单独注册
0 条评论
下一页