title: Spring, how to broadcast message to connected clients using websockets?
body: <p>I am trying to use websockets in my app. I have followed this tutorial:
     <a href="http://spring.io/guides/gs/messaging-stomp-websocket/" rel="noreferrer">http://spring.io/guides/gs/messaging-stomp-websocket/</a></p>
  
  <p>It works perfectly.</p>
  
  <p>When one of connected clients press button, this method is called:</p>
  
  <pre><code>@MessageMapping("/hello")
  @SendTo("/topic/greetings")
  public Greeting greeting() throws Exception {
      System.out.println("Sending message...");
      Thread.sleep(1000); // simulated delay
      return new Greeting("hello!");        
  }
  </code></pre>
  
  <p>and message is broadcasted to all of connected clients.</p>
  
  <p>Now i want to modify my server app, that it will broadcast messages periodically (each hour) to all of my connected clients, without interaction from clients.</p>
  
  <p>Something like this(but this is not working obviously):</p>
  
  <pre><code>@Scheduled(fixedRate = 3600000)
  public void sendMessage(){
     try {
     @SendTo("/topic/greetings")     
     greeting();
      } catch (Exception e) {
          e.printStackTrace(); 
      }
  }
  </code></pre>
  
  <p>Thx for advices.</p>