【问题标题】:spring-messaging xml config with stomp and spring-sessions带有 stomp 和 spring-sessions 的 spring-messaging xml 配置
【发布时间】:2015-01-14 01:02:35
【问题描述】:

我正在尝试使用 stomp 设置带有 spring-messaging 的 WebSockets,并使用带有 spring-session 的 redis 支持的会话。我们的应用程序上下文是通过 xml 连接的,并且 spring-session 正在使用应用程序的非 websocket 部分。 websocket的相关配置如下

    <websocket:message-broker application-destination-prefix="/streaming" >
    <websocket:stomp-endpoint path="/data"> 
        <websocket:sockjs session-cookie-needed="false" />
    </websocket:stomp-endpoint>
    <websocket:stomp-broker-relay prefix="/topic" relay-host="${jms_hostname}" relay-port="${jms_stomp_port}" />
    <websocket:client-inbound-channel>
        <websocket:interceptors>
            <ref bean="sessionRepoMessageInterceptor"/>
            <ref bean="authenticationValidationInterceptor" />
            <ref bean="selectorValidationInterceptor" />
            <ref bean="selectorQuotingInterceptor" /> <!-- comes after we have validated the selector, we now shim it so JMS understands it -->
        </websocket:interceptors>
    </websocket:client-inbound-channel>
</websocket:message-broker>

我在这里定义了我认为 spring-session 与 web 套接字集成所必需的 bean:

<bean id="redisSessionBackedWebsocketHandler" class="org.springframework.session.web.socket.server.">
</bean>

<bean id="sessionRepoMessageInterceptor" class="org.springframework.session.web.socket.server.SessionRepositoryMessageInterceptor">
</bean>

 <bean id="webSocketRegistryListener" class="org.springframework.session.web.socket.handler.WebSocketRegistryListener">
 </bean>

但我不确定将它们连接到网络套接字配置的位置,并且无法找到任何有关如何以这种方式执行此操作的文档。

想法?

【问题讨论】:

    标签: spring-websocket spring-messaging spring-session


    【解决方案1】:

    Spring Session WebSocket 包含仅适用于 Java 和注释变体的配置。

    根据 Spring Session Docs AbstractSessionWebSocketMessageBrokerConfigurer 可以实现 Spring Session 和 Spring WebSockets 之间的无缝集成。然而,我们可以看到一些段落,它的作用:

    要挂钩 Spring Session 支持,我们需要确保 ...

    说实话,从 XML 配置这些东西并不容易。

    请随时关注该问题:https://github.com/spring-projects/spring-session/issues/101

    【讨论】:

    • 是的,我在尝试通过 XML 连接它的过程中取得了部分进展,但被卡住了。查看您提出的票证,我可以看到一个解决方案,它可以让我们同时启动并运行,使用 rwinch 建议的混合注释和 XML 配置。谢谢!
    猜你喜欢
    • 2016-07-04
    • 2014-07-30
    • 2018-07-16
    • 1970-01-01
    • 1970-01-01
    • 2015-11-19
    • 2015-01-25
    • 1970-01-01
    • 2017-05-29
    相关资源
    最近更新 更多