iworkh-springboot-websocket-cache
2020-02-09 22:04:35 0 举报
springboot websocket和redis 缓存原理分析原理图
作者其他创作
大纲/内容
group
日志
starter-xx依赖
TX1挂起
sockJsScheduler
自定义controller里方法
sendMessageToSubscribers()
SimpleBrokerRegistration
SimpleKeyGenerator
true
调用目标方法,返回modelAndView
clientOutboundChannelclientOutboundChannelExecutor
RedisConnectionFactory
defaultCacheConfig
BaseService
实现了SmartInitializingSingleton接口,重写了afterSingletonsInstantiated方法.然后通过beanFactory获取CacheManager类型的bean来初始化CacheMange
top
CompositeMessageConverter
继承/包含
@EnableWebSocketMessageBroker
DefaultRedisCacheWriter
handleMessageInternal()
@Caching
BeanFactoryCacheOperationSourceAdvisor
cacheWriter
StringRedisTemplate
ProxyCachingConfiguration
classPath下所有的jar
开始
业务方法
onmessage
onerror
泛型<T>
UserDestinationMessageHandler
SimpleBrokerMessageHandler
ViewResolver视图解析器根据modeAndView得到View并渲染
SimpUserRegistry
SayHelloMBean
web
/user/
N
cache?
secondInterceptor.preHandle
JedisJedisCluster
AbstractMessageChannel
findSubscriptionsInternal()
annotation
brokerChannelbrokerChannelExecutor
TX1 Start
TX4 Start
onclose
SpringMVC的handlerMapping存在否
float:left
onError
@MessageMapping@SendTo@SubscribeMapping
只要满足最底线,先遇到谁就选谁
Exception
HelloMBean
XxxServicePoxy(代理类)
+ get(params):returnType+ upate(params)+ delete(id)
ListenableFutureReturnValueHandler
/endpointSocket
@CacheEvict
调用的是否是代理类?
StompSubProtocolHandler
目标存储位置
?
MessageHandler
WebSocketHandlerDecorator
configuration
extends
client2
RedisCache
client3
DefaultJCacheOperationSource
DelegatingWebSocketMessageBrokerConfiguration
结束
spring.cache.xxx=YYYY
DB: Redis
RedisCacheConfiguration
root
super
add
StudentDao
HandlerExceptionResolver解析异常,得到新的modeAndView
HttpSession中存在匹配入参?
SendToMethodReturnValueHandler
cluster A
bottom
handleMessageToClient()
返回值
end
StudentService
是否存在方法使用@ModelAttribute?
session
doSend()
@Bean
自定义的一些特殊目录
就近原则
TX1 End
@Autowired
!important
SubProtocolWebSocketHandler
SendTask <- MessageHandlingRunnable
根据配置文件,pom依赖,注解等,springboot启动初始化时,就决定了是单机还是集群?是哨兵还是集群模式?
cacheResolver
clientOutboundChannel
SockJsWebSocketHandler
MyClassLoader
Namespace
appender
MessageChannel
TX2 End
ExecutorSubscribableChannel
queue
cacheManager
sendInternal()
+
Y
UpgradeProcessorInternal
onopen
endPoint
相对路径:相对于location绝对路径:系统/根
BaseDao
RedisCacheManger
CacheInterceptor
从命中的缓存中,找到一条结果返回
IOException
TX3 Start
service
TX2 Start
BeanFactoryJCacheOperationSourceAdvisor
NioEndpoint
JedisConnectionFactory
Sayhello
subProtocolWebSocketHandler
@ControllerAdvice注解类里的@ExceptionHandler方法匹配
send()
secondInterceptor.postHandle
firstInterceptor.preHandle
SimpMessagingTemplate
cluster B
imp
启动线程执行
instances 1
没选中/继承
endPonit
onMessage
firstInterceptor.afterCompletion
onOpen
BootStrap
stompWebSocketHandlerMapping
权重大的样式生效
logger
子
是否元素选中
call
JCacheInterceptor
无
DB:Redis
@Compoent
LoggerAspectOrder(20)
DefaultSubscriptionRegistry
RedisConnection?RedisClusterConnection?RedisSentinelConnection?
拦截器的preHandler方法处理
WebMvcStompWebSocketEndpointRegistration
@Controller
properties/yaml
@ControllerAdvice
@Cacheable
根据请求从handlerMappings中获取HandlerExecutionChain
handleMessage()
TX4 End
simpAnnotationMethodMessageHandlersimpleBrokerMessageHandlerstompBrokerRelayMessageHandleruserDestinationMessageHandleruserRegistryMessageHandler
Manager
HandlerMapping
有
从handlerMappings中获取HandlerAdpater
执行放到结果交给
ExtClassLoader
Error
RedisStringCommands的实现类
不一样
拦截器的afterCompletion方法处理
TX3
convertAndSendToUser()
sendTo()
spring
CacheOperationContexts
topic
StandardWebSocketHandlerAdapter
@Service
UserDestinationResolver
CacheOperationSource
handleReturnValue()
keyGenerator
AbstractMessageBrokerConfiguration
handerAdpter.handle
left
向上通配符<? super T>
messagingTemplate
不同
父
N,没有满足
right
WebSocketMessageBrokerConfigurationSupport
近的样式生效
DispatcherServlet
LettuceConnectionConfiguration
instances 2
WebSocketHandler
AutoProxyRegistrar
SystemClassLoader
CacheAutoConfiguration
权限
Message
TX1继续
是否存在Exception
WsFrameBase
StompBrokerRelayRegistration
CarDao
返回静态资源
-
ProxyJCacheConfiguration
SimpleMappingExceptionResolver里自定义的mpping异常匹配
secondInterceptor.afterCompletion
定位祖先元素的边框
是否有祖先定位
CacheOperationContext
firstInterceptor.postHandle
注解方式从缓存中查询
个人bank业务
对应key的对象,传给方法参数
websocket
首屏页面边框
messageBrokerTaskScheduler
sendToClient()
sendInternal
sendToUser()
Notification
AnnotationCacheOperationSource
选中
事务
匹配handler所在类,所有@ModelAttribute方法都会执行一边,是否有满足入参的key?
中间临时目录
false
向下通配符<? extends T>
reidsTemplate
convertAndSend()
CompletableFutureReturnValueHandler
app
controller方法注解和消息destination进行匹配
webserver/tomcat
exceptionHandler
@CachePut
listener
tcp三次握手
AppClassLoader
@EnableCaching
WebMvcStompEndpointRegistry
Throwable
clientInboundChannelclientInboundChannelExecutor
dispatcher.render
是否存在静态资源的配置<mvc:defuault-servlet-handler/>
Hello
returnValueHandlers
registrations
springMVC
一样近
类上@SessionAttributes是否存在满足条件的?
TX4
...
Cache
sendMessage
MessageBrokerRegistry
LettuceConnectionFactory
web.xml里配置的url-pattern
SimpleCacheErrorHandler
server
@Repository
JedisConnectionConfiguration
CacheConfigurationImportSelector
start
RedisClientRedisClusterClient
XxxkService(被代理类)
spring.factories
404
RuntimeException
JRE/lib/ext/*.jar
user
CachingConfigurationSelector
后面样式为准
CacheProperties
WebSocketSession
拦截器的postHandler方法处理
WebSocketAnnotationMethodMessageHandler
DefaultHandlerExceptionResolver解析定义的特殊异常匹配
WsHttpUpgradeHandler
/app/
ExceptionHandlerExceptionResovler
满足条件的所有RedisCache的集合
onClose
TX3 End
基准/最底线
TX2
RedisAutoConfiguration
Spring AOP?
当前handler/controller里的@ExceptionHandler方法匹配
clientInboundChannel
client1
WebSocketServerSockJsSession
Y,满足key
?
MBeanServer
JRE/lib/rt.jar
stompHandler
RedisCacheManager
CheckAspectOrder(10)
spring.servlet.multipart.location配置\\work\\Tomcat\\localhost\\ROOT\\目录
SubscriptionMethodReturnValueHandler
ResponseStatusExceptionResolver解析@ResponseStatus的异常进行匹配
Book业务
相同
CarService
application
0 条评论
下一页