Email code makes code slower in java spring MVC

I added that this is my controller

@RequestMapping(value = "/persons/add", method = RequestMethod.POST)
        public String add(@Valid @ModelAttribute("personAttribute") Person person,
                BindingResult result) {
        logger.debug("Received request to add new person");


        SimpleMailMessage mailMessage = new SimpleMailMessage();

        mailMessage.setTo("someone@abc.com");
        mailMessage.setSubject("This is the test message for testing gmail smtp server using spring mail");
        mailMessage.setFrom("abc@gmail.com");
        mailMessage.setText("This is the test message for testing gmail smtp server using spring mail. \n" +
                "Thanks \n Regards \n Saurabh ");
        mailSender.send(mailMessage);


        if (result.hasErrors())
                return "hibernate/addpage";
        else
        personService.add(person);

                return "hibernate/addedpage";
    }

NOw takes 5-6 seconds after clicking the add button

0
source share
4 answers

, API. . , . , . Google java- spring; . , , , ( ).

- , localhost, , . , , , , . , ?

+2

?

- . ?

, , gmail ....

+1

, . .

; API ( Thread ).

+1
source

Better use the Async email service.

Spring TaskExecutor for Mail

0
source

All Articles