parent
bf1561d092
commit
7a535d9dd2
@ -0,0 +1,25 @@
|
|||||||
|
package com.xjs.business.webmagic;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.constant.ServiceNameConstants;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.xjs.business.webmagic.factory.RemoteWebmagicWeiXinSouGouFactory;
|
||||||
|
import com.xjs.business.webmagic.factory.RemoteWebmagicY2048communityFactory;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 2048远程调用
|
||||||
|
*
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-06-20
|
||||||
|
*/
|
||||||
|
@FeignClient(contextId = "remoteWebmagicY2048communityFeign",
|
||||||
|
value = ServiceNameConstants.BUSINESS_WEBMAGIC_SERVICE,
|
||||||
|
fallbackFactory = RemoteWebmagicY2048communityFactory.class)
|
||||||
|
public interface RemoteWebmagicY2048communityFeign {
|
||||||
|
|
||||||
|
@GetMapping("/y2048community/taskForPRC")
|
||||||
|
R y2048communityTaskForPRC();
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
|||||||
|
package com.xjs.business.webmagic.factory;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.xjs.business.webmagic.RemoteWebmagicY2048communityFeign;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 2048降级
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-06-20
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@Log4j2
|
||||||
|
public class RemoteWebmagicY2048communityFactory implements FallbackFactory<RemoteWebmagicY2048communityFeign> {
|
||||||
|
@Override
|
||||||
|
public RemoteWebmagicY2048communityFeign create(Throwable cause) {
|
||||||
|
return new RemoteWebmagicY2048communityFeign() {
|
||||||
|
@Override
|
||||||
|
public R y2048communityTaskForPRC() {
|
||||||
|
log.error("2048 爬虫定时任务 降级------服务可能正在运行");
|
||||||
|
return R.fail("降级处理------服务可能正在运行");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package com.xjs.job.task.webmagic;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.xjs.business.webmagic.RemoteWebmagicY2048communityFeign;
|
||||||
|
import com.xjs.job.aop.TaskLog;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 2048定时任务
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-06-20
|
||||||
|
*/
|
||||||
|
@Component("Y2048communityTask")
|
||||||
|
@Log4j2
|
||||||
|
public class Y2048communityTask {
|
||||||
|
@Resource
|
||||||
|
private RemoteWebmagicY2048communityFeign remoteWebmagicY2048communityFeign;
|
||||||
|
|
||||||
|
@TaskLog(name = "2048社区爬虫任务")
|
||||||
|
public void execute() {
|
||||||
|
log.info("---------------爬虫-2048定时任务Start-------------------");
|
||||||
|
|
||||||
|
R r = remoteWebmagicY2048communityFeign.y2048communityTaskForPRC();
|
||||||
|
|
||||||
|
log.info("爬虫-2048定时任务结果:code={},msg={},data={}",r.getCode(),r.getMsg(),r.getData());
|
||||||
|
log.info("---------------爬虫-2048定时任务end---------------------");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in new issue