forked from microsoft/azure-spring-boot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueueSendController.java
More file actions
36 lines (26 loc) · 1.01 KB
/
QueueSendController.java
File metadata and controls
36 lines (26 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See LICENSE in the project root for
* license information.
*/
package sample.jms.queue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class QueueSendController {
private static final String QUEUE_NAME = "que001";
private static final Logger logger = LoggerFactory.getLogger(QueueSendController.class);
@Autowired
private JmsTemplate jmsTemplate;
@PostMapping("/queue")
public String postMessage(@RequestParam String message) {
logger.info("Sending message");
jmsTemplate.convertAndSend(QUEUE_NAME, new User(message));
return message;
}
}