Related with the question autowire simpmessagingtemplate
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 ?
Example:
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");
is not being received by the browser. Everything else works fine.
The beans configuration is:
<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>
Thanks in advance.
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 has been create in JetBrains to solve this problem.