【发布时间】:2016-06-09 19:03:47
【问题描述】:
我一直在尝试使用 spring 集成和 web socket。不得不说,web sockets对我来说真的很陌生,可能我还没有了解一些基础知识。
我想做什么。我的后端正在生成消息并将它们放入 Spring-Integration 系统。这一切都很好。我的想法是,我不确定这是否有效。我有一个至少消息到达的频道,一个发布订阅者频道。现在我想使用 int-websocket.outbound-channel-adapter 将该消息推送到浏览器。
我的发布订阅频道名为ticketOutgoingChannel
我的配置如下:
<bean id="webSocketSessionStore" class="org.springframework.integration.metadata.SimpleMetadataStore"/>
<int-websocket:server-container id="serverWebSocketContainer" path="sass">
<int-websocket:sockjs />
</int-websocket:server-container>
<int:chain input-channel="ticketOutgoingChannel">
<int:header-enricher>
<int:header
name="#{T(org.springframework.messaging.simp.SimpMessageHeaderAccessor).SESSION_ID_HEADER}"
expression="webSocketSessionStore.sessionId"
/>
</int:header-enricher>
<int-websocket:outbound-channel-adapter container="serverWebSocketContainer" />
</int:chain>
我现在的一个问题是,我不知道如何获取 Websocket 的 sessionId,如果有,如何将其添加到消息中。
这是消息到达的通道,我想推送给客户端。
<int:publish-subscribe-channel
id="ticketOutgoingChannel"
datatype="...model.Ticket"
/>
请在 xml 中提供提示。我更喜欢 STS 图形支持的 xml cos 以便更好地理解。稍后我确定我会使用 Java-Config。
提前谢谢你。
【问题讨论】:
标签: websocket push-notification spring-integration spring-websocket