|
@@ -13,37 +13,10 @@ import org.springframework.stereotype.Component;
|
|
|
@Component
|
|
|
public class ScheduleJob {
|
|
|
|
|
|
- @Value("${rocketmq.autoScaling.num.normal}")
|
|
|
- private String baseNum;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private RabbitMqProducer rabbitMqProducer;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ScalingService scalingService;
|
|
|
-
|
|
|
- @Value("${queue.modeling.modeling-call}")
|
|
|
- private String queueModelingCall;
|
|
|
@Autowired
|
|
|
private IScene3dNumService scene3dNumService;
|
|
|
|
|
|
|
|
|
- @Scheduled(cron = "${rocketmq.autoScaling.corn:0 0/5 8-21 * * ?}")
|
|
|
- public void job8() {
|
|
|
- try {
|
|
|
- //当mq排队数大于指定数量时使用弹性升缩
|
|
|
- int mqNum = rabbitMqProducer.getMessageCount(queueModelingCall);
|
|
|
- log.info("每5分钟查询一次排队队列,mqNum:" + mqNum);
|
|
|
- if(mqNum - Integer.parseInt(baseNum) > 0){
|
|
|
- log.info("使用弹性升缩开启一台ECS");
|
|
|
- log.info(scalingService.createEcs());
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("弹性升缩开启失败!", e);
|
|
|
- log.error(e.getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 定时生成场景码,间隔1小时执行一次,项目启动一秒后执行一次
|
|
|
*/
|