如何使用ExecutorSubscribableChannel [英] How to use ExecutorSubscribableChannel

查看:542
本文介绍了如何使用ExecutorSubscribableChannel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

​​ autowire simpmessagingtemplate 相关的问题

我遇到类ExecutorSubscribableChannel的问题。我希望服务器向浏览器发送异步消息。 如何正确使用ExecutorSubscribableChannel

I am having problem the class ExecutorSubscribableChannel. I want the server to send a asynchronous message to the browser. How can I use properly 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() + "!");
    }
}

但是我发送的你好世界文字在行

but the "hello world" text that I am sending in the line

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中的一个错误而写的。响应在​​无法自动装配。找不到SimpMessagingTemplate类型的bean

This question was written due a bug in Intellij IDEA. The response is in Could not autowire. No beans of SimpMessagingTemplate type found

A ticket 来解决这个问题。

A ticket has been create in JetBrains to solve this problem.

这篇关于如何使用ExecutorSubscribableChannel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆