简体   繁体   English

如何对 Spring @Scheduled 任务进行性能和负载测试

[英]How can I do Performance & Load Testing for Spring @Scheduled task

I want to run Performance & Load Test for a Spring @Scheduled task using Apache JMeter if possible.如果可能,我想使用 Apache JMeter 对 Spring @Scheduled 任务运行性能和负载测试。

  1. Does it support this?它支持这个吗?
  2. And how can I achieve it?我怎样才能实现它?

I'm using Spring 5 (non boot) and JMeter 5.4.1我正在使用 Spring 5(非启动)和 JMeter 5.4.1

Thank you谢谢

Edit 1: My scheduled task is configured as below编辑1:我的计划任务配置如下

package com.mypackage.impl;

import com.mypackage.service.NotificationBatchService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
@Transactional
public class NotificationBatchServiceImpl implements NotificationBatchService {

    @Override
    @Scheduled(cron = "0 0 */2 * * *")
    public void synchronizeNotificationUploadDocument() {
        // database transactions
        // HTTP requests
    }
}

You should extract the code inside of the method synchronizeNotificationUploadDocument to a service and then load test this service.您应该将方法synchronizeNotificationUploadDocument中的代码提取到服务中,然后对该服务进行负载测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM