我希望在Spring 4中创建多个message实例。
<websocket:message-broker application-destination-prefix="/App1" >
<websocket:stomp-endpoint path="/path1">
<websocket:sockjs/>
</websocket:stomp-endpoint>
<websocket:simple-broker prefix="/topic"/>
</websocket:message-broker>
<websocket:message-broker application-destination-prefix="/App2">
<websocket:stomp-endpoint path="/path2">
<websocket:sockjs/>
</websocket:stomp-endpoint>
<websocket:simple-broker prefix="/topic"/>
</websocket:message-broker>在我的控制器里,我是自动装配SimpMessagingTemplate的。
我得到了以下例外:
原因: org.springframework.beans.factory.BeanCreationException:无法自动显示字段: org.springframework.messaging.simp.SimpMessagingTemplate com.cdk.phoenix.app.controller.tools.tail.LogTailController.template;嵌套 异常是org.springframework.beans.factory.NoUniqueBeanDefinitionException:,没有org.springframework.messaging.simp.SimpMessagingTemplate类型的限定bean 定义:预期的单个匹配bean,但发现2: org.springframework.messaging.simp.SimpMessagingTemplate#0,org.springframework.mes saging.simp.SimpMessagingTemplate#1
如何为不同的消息代理创建唯一的SimpMessagingTemplate实例?
发布于 2015-08-03 11:45:23
作为临时修复,我添加了一个限定符如下:
@Autowired
@Qualifier("org.springframework.messaging.simp.SimpMessagingTemplate#1")
SimpMessagingTemplate template;除了日志中显示的一条错误消息外,所有操作都按预期进行:
*ERROR* SubProtocolWebSocketHandler: handleMessage - No session for [Payload byte[0]][Headers={simpMessageType=CONNECT_ACK, nativeHeaders={}, simpConnectMessage=[Payload byte[0]][Headers={simpMessageType=CONNECT, stompCommand=CONNECT, nativeHeaders={heart-beat=[10000,10000], accept-version=[1.1,1.0]}, simpSessionAttributes={}, simpSessionId=katcl9hg, id=2627fb55-4c8a-365c-7211-e543578e9ffb, timestamp=1438601578923}], simpSessionId=katcl9hg, id=4b4f7b0e-237a-7b3b-7d3e-247096e82b51, timestamp=1438601578924}]是否存在修复此错误的方法?
谢谢,桑托什
https://stackoverflow.com/questions/31108966
复制相似问题