发布
社区首页 >问答首页 >Spring (IntegrationFlowContext):动态注册到同一个websocket服务器的新路径

Spring (IntegrationFlowContext):动态注册到同一个websocket服务器的新路径
EN

Stack Overflow用户
提问于 2020-02-26 06:21:21
回答 1查看 343关注 0票数 1

我试图使用JavaDsl实现spring解决方案,方法是遵循链接即https://github.com/joshlong/techtips/tree/master/examples/spring-integration-4.1-websockets-example

我通过订阅路径(即/messages)和我的stomp客户端成功地测试了它。

接下来,通过向IntegrationFlowContext注册集成流,我尝试了同样的方法。

它在服务器端成功执行,但是当我试图通过我的stomp客户端提出请求时,我收到了404的例外。

在浏览日志时,我发现以前"AbstractHandlerMapping“是映射到ResourceHttpRequestHandler的,现在是映射到ResourceHttpRequestHandler了。

与Spring管理的集成流(成功)

代码语言:javascript
代码运行次数:0
复制
DEBUG [http-nio-8081-exec-1] o.s.c.l.LogFormatUtils: GET "/messages/websocket", parameters={}
DEBUG [http-nio-8081-exec-1] o.s.w.s.h.AbstractHandlerMapping: Mapped to org.springframework.web.socket.sockjs.support.SockJsHttpRequestHandler@46185a1b
DEBUG [http-nio-8081-exec-1] o.s.w.s.s.s.AbstractSockJsService: Processing transport request: GET http://localhost:8081/messages/websocket
DEBUG [http-nio-8081-exec-1] o.s.w.s.FrameworkServlet: Completed 101 SWITCHING_PROTOCOLS
DEBUG [http-nio-8081-exec-1] o.s.w.s.h.LoggingWebSocketHandlerDecorator: New StandardWebSocketSession[id=e11b5ef5-d2e5-e5c7-819d-493f42f4a7c8, uri=ws://localhost:8081/messages/websocket]

和IntegrationFlow上下文托管流(Failure)

代码语言:javascript
代码运行次数:0
复制
DEBUG [http-nio-8081-exec-1] o.s.c.l.LogFormatUtils: GET "/messages/websocket", parameters={}
DEBUG [http-nio-8081-exec-1] o.s.w.s.h.AbstractHandlerMapping: Mapped to ResourceHttpRequestHandler ["classpath:/META-INF/resources/", "classpath:/resources/", "classpath:/static/", "classpath:/public/", "/"]
DEBUG [http-nio-8081-exec-1] o.s.w.s.r.ResourceHttpRequestHandler: Resource not found
DEBUG [http-nio-8081-exec-1] o.s.w.s.FrameworkServlet: Completed 404 NOT_FOUND
DEBUG [http-nio-8081-exec-1] o.s.c.l.LogFormatUtils: "ERROR" dispatch for GET "/error", parameters={}
DEBUG [http-nio-8081-exec-1] o.s.w.s.h.AbstractHandlerMapping: Mapped to org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController#error(HttpServletRequest)
DEBUG [http-nio-8081-exec-1] o.s.w.s.m.m.a.AbstractMessageConverterMethodProcessor: Using 'application/json', given [*/*] and supported [application/json, application/*+json, application/json, application/*+json]
DEBUG [http-nio-8081-exec-1] o.s.c.l.LogFormatUtils: Writing [{timestamp=Tue Feb 25 17:06:58 IST 
EN

回答 1

Stack Overflow用户

发布于 2020-02-26 19:43:39

由于Mapped to ...中的getHandler(HttpServletRequest request)逻辑,您有一个不同的AbstractHandlerMapping

代码语言:javascript
代码运行次数:0
复制
Object handler = getHandlerInternal(request);
    if (handler == null) {
        handler = getDefaultHandler();
    }
    if (handler == null) {
        return null;
    }
    // Bean name or resolved handler?
    if (handler instanceof String) {
        String handlerName = (String) handler;
        handler = obtainApplicationContext().getBean(handlerName);
    }

    HandlerExecutionChain executionChain = getHandlerExecutionChain(handler, request);

    if (logger.isTraceEnabled()) {
        logger.trace("Mapped to " + handler);
    }

我们不支持动态WS端点,因为我们没有在内部WebSocketHandlerMappingFactoryBean中扫描它们。

请随意提出一个GH问题的https://github.com/spring-projects/spring-integration/issues,我们将看看我们可以做什么。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60407907

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档