Java @已计划使用cron表达式突然停止工作
我知道这个问题会反复出现,但我尝试了所有的建议,但没有任何效果。 我使用的是Spring1.4.3。 我使用的是elastic beanstalk,因此我的dev EC2实例类型为t2.small,而prod的EC2实例类型为t2.large 我一直在尝试的工作直到今天,突然它停止了,没有错误或任何东西…(不仅仅是这份工作是我项目中所有的工作) 我的配置是:Java @已计划使用cron表达式突然停止工作,java,spring,cron,scheduled-tasks,Java,Spring,Cron,Scheduled Tasks,我知道这个问题会反复出现,但我尝试了所有的建议,但没有任何效果。 我使用的是Spring1.4.3。 我使用的是elastic beanstalk,因此我的dev EC2实例类型为t2.small,而prod的EC2实例类型为t2.large 我一直在尝试的工作直到今天,突然它停止了,没有错误或任何东西…(不仅仅是这份工作是我项目中所有的工作) 我的配置是: @Configuration @EnableAsync @EnableScheduling public class AppC
@Configuration
@EnableAsync
@EnableScheduling
public class AppConfig{
@Bean(destroyMethod = "shutdown")
public Executor taskScheduler() {
return Executors.newScheduledThreadPool(5);
}
}
我正在尝试的工作非常简单:
@Service
open class TestProcessing {
private val logger = LoggerFactory.getLogger(this.javaClass)
@Scheduled(fixedDelay = 5000)
fun startProcessing2(){
logger.info("Test2 Job")
}
}
我的主要意见是:
@SpringBootApplication(exclude = EndpointMBeanExportAutoConfiguration.class)
public class ApiServerApplication {
public static void main(String[] args) {
new SpringApplicationBuilder(ApiServerApplication.class).run(args);
}
}
该职位要求:
@ResponseBody
@RequestMapping(
path = arrayOf("", "/"),
method = arrayOf(RequestMethod.POST),
consumes = arrayOf(MediaType.APPLICATION_JSON_UTF8_VALUE))
fun insertDispenserRecordsList(@RequestHeader(name = "xg-BAddress", required = false) reporter: String?,
@Valid @RequestBody dispenserRecords: DispenserRecordsList<DispenserRecordInput>,
bindingResult: BindingResult): ResponseEntity<*> {
if (bindingResult.hasErrors()) {
throw exception(bindingResult)
}
dispenserRecordsService.insertDispenserRecordsList(reporter, dispenserRecords.dispenserRecords)
return ResponseEntity<Any>(HttpStatus.OK)
如果你需要更多的细节,请让我知道。。。
感谢您的帮助情况指出,这是因为在开发中,每个POST请求都在执行某些任务或调用任何其他等待其响应的外部系统。 一种可能的解决方案是为POST请求定义超时,该超时应小于@SCDULED time。 对于POST请求,我也有同样的问题,它从DB获取记录列表
@RequestMapping(method = RequestMethod.POST)
ResponseEntity<?> add(@PathVariable String userId, @RequestBody Bookmark input) {
this.validateUser(userId);
return this.accountRepository
.findByUsername(userId)
.map(account -> {
Bookmark result = bookmarkRepository.save(new Bookmark(account,
input.getUri(), input.getDescription()));
URI location = ServletUriComponentsBuilder
.fromCurrentRequest().path("/{id}")
.buildAndExpand(result.getId()).toUri();
return ResponseEntity.created(location).build();
})
.orElse(ResponseEntity.noContent().build());
}
@RequestMapping(method=RequestMethod.POST)
ResponseEntity添加(@PathVariable String用户标识,@RequestBody书签输入){
这是validateUser(userId);
返回此.accountRepository
.findByUsername(用户ID)
.map(帐户->{
书签结果=书签存储库.save(新书签(帐户、,
input.getUri(),input.getDescription());
URI位置=ServletUriComponentsBuilder
.fromCurrentRequest().path(“/{id}”)
.buildAndExpand(result.getId()).toUri();
返回ResponseEntity.created(location.build();
})
.orElse(ResponseEntity.noContent().build());
}
这将等待服务的响应。在您的情况下,POST请求必须异步等待响应,否则它不能在Prod或Local中运行 您所说的POST请求是异步的吗?@Rezwan没有任何可能导致此问题的解决方案或解释?抱歉,我不理解解决方案,我添加了发生的POST请求,您能帮助我如何更改它以使其工作吗?等待部分在哪里?添加“spring.mvc.async.request timeout=10000”在你的application.properties文件中,你正在使用Rest模板Bean进行Rest调用??不,我不是。。。我使用的是gradle而不是mvc…我应该添加什么来代替mvc?
@RequestMapping(method = RequestMethod.POST)
ResponseEntity<?> add(@PathVariable String userId, @RequestBody Bookmark input) {
this.validateUser(userId);
return this.accountRepository
.findByUsername(userId)
.map(account -> {
Bookmark result = bookmarkRepository.save(new Bookmark(account,
input.getUri(), input.getDescription()));
URI location = ServletUriComponentsBuilder
.fromCurrentRequest().path("/{id}")
.buildAndExpand(result.getId()).toUri();
return ResponseEntity.created(location).build();
})
.orElse(ResponseEntity.noContent().build());
}