I have the following piece of code:
@Controller
@EnableScheduling
public class QuoteController {
@Scheduled(fixedDelay=5000)
@SendTo(value="/topic/quote")
public String sendPrice() {
return "message from scheduler";
}
}
And it doesn't send the message to the channel. But the following code works:
@Controller
@EnableScheduling
public class QuoteController {
@Autowired
public SimpMessageSendingOperations messagingTemplate;
@Scheduled(fixedDelay=5000)
public String sendPrice() {
messagingTemplate.convertAndSend("/topic/quote", "message from scheduler");
}
}