Last active
May 13, 2021 11:57
-
-
Save sonus21/24480164ec79ad405e2d59ada1195f1c to your computer and use it in GitHub Desktop.
Controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @RestController | |
| @RequiredArgsConstructor(onConstructor = @__(@Autowired)) | |
| @Slf4j | |
| public class Controller { | |
| private @NonNull RqueueMessageEnqueuer rqueueMessageEnqueuer; | |
| @Value("${email.queue.name}") | |
| private String emailQueueName; | |
| @Value("${invoice.queue.name}") | |
| private String invoiceQueueName; | |
| @Value("${invoice.queue.delay}") | |
| private Long invoiceDelay; | |
| @GetMapping("email") | |
| public String sendEmail( | |
| @RequestParam String email, @RequestParam String subject, @RequestParam String content) { | |
| log.info("Sending email"); | |
| rqueueMessageEnqueuer.enqueue(emailQueueName, new Email(email, subject, content)); | |
| return "Please check your inbox!"; | |
| } | |
| @GetMapping("invoice") | |
| public String generateInvoice(@RequestParam String id, @RequestParam String type) { | |
| log.info("Generate invoice"); | |
| rqueueMessageEnqueuer.enqueueIn(invoiceQueueName, new Invoice(id, type), invoiceDelay); | |
| return "Invoice would be generated in " + invoiceDelay + " milliseconds"; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment