Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/399.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何使用BabeChannel_Java_Spring_Stomp_Spring Messaging - Fatal编程技术网

Java 如何使用BabeChannel

Java 如何使用BabeChannel,java,spring,stomp,spring-messaging,Java,Spring,Stomp,Spring Messaging,与问题有关 我在广播频道上遇到了问题。我希望服务器向浏览器发送一条异步消息如何正确使用BabeChannel 例如: public class GreetingController { @Autowired private SimpMessagingTemplate template; public void setTemplate(SimpMessagingTemplate template) { this.template = template;

与问题有关

我在广播频道上遇到了问题。我希望服务器向浏览器发送一条异步消息如何正确使用BabeChannel

例如:

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");
浏览器未接收到。其他一切都很好

bean配置为:

<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中的一个错误而写的。答案是肯定的


为了解决这个问题,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"/>