1 package de.spring.webservices.rest.controller;
3 import java.time.LocalDateTime;
5 import org.springframework.beans.factory.annotation.Autowired;
6 import org.springframework.messaging.simp.SimpMessagingTemplate;
7 import org.springframework.stereotype.Controller;
8 import org.springframework.web.bind.annotation.RequestMapping;
9 import org.springframework.web.bind.annotation.RequestMethod;
13 public class GreetingController {
15 private SimpMessagingTemplate template;
18 public GreetingController(SimpMessagingTemplate template) {
19 this.template = template;
22 // @MessageMapping("/greeting")
23 // public String handle(String greeting) {
24 // return "[" + LocalDateTime.now() + ": " + greeting;
27 @RequestMapping(path="/greetings", method=RequestMethod.POST)
28 public void handle(String greeting) {
29 String text = "[" + LocalDateTime.now() + "]:" + greeting;
30 this.template.convertAndSend("/topic/greeting", text);