Spring 引导 - 在处理请求正文时引入等待时间
Spring Boot - introduce wait time when processing request body
我有一个 Spring 带有 Jetty 的启动应用程序,它接受传入的请求。是否有任何类型的 Spring 引导内置机制可以在 处理每条消息(等待 1 秒,处理 1 条消息,等待 1 秒,处理 1 条消息)之间添加延迟 ...无批量处理),例如 1 秒而不是 TimeUnit.SECONDS.sleep(1),更不用说这里是否安全了。谢谢。
@RestController
public class NotificationController {
@RequestMapping(
method = RequestMethod.POST,
consumes = MediaType.TEXT_XML_VALUE)
@ResponseStatus(value = HttpStatus.OK)
public void notification(@RequestBody String payload) {
// handle payload here
} }
您可以定义一个执行 Thread.sleep()
的过滤器 (https://www.baeldung.com/spring-boot-add-filter)
我有一个 Spring 带有 Jetty 的启动应用程序,它接受传入的请求。是否有任何类型的 Spring 引导内置机制可以在 处理每条消息(等待 1 秒,处理 1 条消息,等待 1 秒,处理 1 条消息)之间添加延迟 ...无批量处理),例如 1 秒而不是 TimeUnit.SECONDS.sleep(1),更不用说这里是否安全了。谢谢。
@RestController
public class NotificationController {
@RequestMapping(
method = RequestMethod.POST,
consumes = MediaType.TEXT_XML_VALUE)
@ResponseStatus(value = HttpStatus.OK)
public void notification(@RequestBody String payload) {
// handle payload here
} }
您可以定义一个执行 Thread.sleep()
的过滤器 (https://www.baeldung.com/spring-boot-add-filter)