문제

quoty 님과 관련된 자동 동아 SimpMessagingTemplate / P>

클래스 ExecUtorSubscribableChannel에 문제가 있습니다.서버가 비동기 메시지를 브라우저에 보낼 수 있습니다. 어떻게 executorSubscribableChannel 을 적절하게 사용할 수 있습니까?

예 :

public class GreetingController {


    @Autowired
    private SimpMessagingTemplate template;

    public void setTemplate(SimpMessagingTemplate template) {
        this.template = template;
    }

    @MessageMapping("/hello")
    @SendTo("/topic/greetings")
    public Greeting greeting(HelloMessage message) throws Exception {
        Thread.sleep(5000); // simulated delay
        this.template.convertAndSend("/topic/greetings", "Hello World");
        return new Greeting("Hello, " + message.getName() + "!");
    }
}
.

그러나 내가 줄을 보내고있는 "Hello World"텍스트

this.template.convertAndSend("/topic/greetings", "Hello World");
.

는 브라우저에서 수신하지 않습니다.모든 것이 잘 작동합니다.

beans 구성은 다음과 같습니다.

<bean id="executorSC" class="org.springframework.messaging.support.ExecutorSubscribableChannel"/>

<bean id="template" class="org.springframework.messaging.simp.SimpMessagingTemplate">
    <constructor-arg index="0" ref="executorSC"/>
</bean>
.

미리 감사드립니다.

도움이 되었습니까?

해결책

이 질문은 Intellij Idea의 버그로 인해 작성되었습니다.응답은 자동으로 바로 할 수 없습니다.SimpMessagingTemplate 유형의 콩 없음

a 티켓 이 문제를 해결하려면 jetbrains에서 작성되었습니다.

다른 팁

이 구성을 사용해보십시오

<websocket:message-broker
    application-destination-prefix="/app">
    <websocket:stomp-endpoint path="/ws">
        <websocket:sockjs />
    </websocket:stomp-endpoint>
    <websocket:simple-broker prefix="/topic/greetings" />
</websocket:message-broker>
.

대신

<bean id="executorSC" class="org.springframework.messaging.support.ExecutorSubscribableChannel"/>
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top