增加自定义异常处理,当任务发生异常的时候钉钉通知
This commit is contained in:
@@ -9,11 +9,14 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.context.annotation.ImportResource;
|
||||
|
||||
import com.fangjia.job.fsh.config.InitBeanConfig;
|
||||
|
||||
@SpringBootApplication
|
||||
@ImportResource(locations = { "classpath:applicationContext*.xml" })
|
||||
public class FshJobApp {
|
||||
|
||||
public static void main(String[] args) {
|
||||
InitBeanConfig.init();
|
||||
new SpringApplicationBuilder().sources(FshJobApp.class).web(false).run(args);
|
||||
try {
|
||||
new CountDownLatch(1).await();
|
||||
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
package com.fangjia.job.fsh.config;
|
||||
|
||||
import com.cxytiandi.jdbc.CacheData;
|
||||
|
||||
public class InitBeanConfig {
|
||||
|
||||
public static void init() {
|
||||
CacheData.put("com.fangjia.job.fsh.po.AdVisitLog.id", "id");
|
||||
CacheData.put("com.fangjia.job.fsh.po.AdVisitLog.eid", "eid");
|
||||
CacheData.put("com.fangjia.job.fsh.po.AdVisitLog.uid", "uid");
|
||||
CacheData.put("com.fangjia.job.fsh.po.AdVisitLog.visit_time", "visitTime");
|
||||
CacheData.put("com.fangjia.job.fsh.po.AdVisitLog.url", "url");
|
||||
CacheData.put("com.fangjia.job.fsh.po.AdVisitLog.adid", "adid");
|
||||
CacheData.put("com.fangjia.job.fsh.po.AdVisitLog.ad_position", "adPosition");
|
||||
CacheData.put("com.fangjia.job.fsh.po.Enterprise.id", "id");
|
||||
CacheData.put("com.fangjia.job.fsh.po.Enterprise.name", "name");
|
||||
CacheData.put("com.fangjia.job.fsh.po.Enterprise.address", "address");
|
||||
CacheData.put("com.fangjia.job.fsh.po.Enterprise.website", "website");
|
||||
CacheData.put("com.fangjia.job.fsh.po.Enterprise.open_api_token", "openApiToken");
|
||||
CacheData.put("com.fangjia.job.fsh.po.Enterprise.open_api_uname", "openApiName");
|
||||
CacheData.put("com.fangjia.job.fsh.po.Enterprise.open_api_pass", "openApiPass");
|
||||
CacheData.put("com.fangjia.job.fsh.po.Enterprise.enterprise_person", "enterprisePerson");
|
||||
CacheData.put("com.fangjia.job.fsh.po.Enterprise.enterprise_person_mobile", "enterprisePersonMobile");
|
||||
CacheData.put("com.fangjia.job.fsh.po.Enterprise.enterprise_person_telphone", "enterprisePersonTelPhone");
|
||||
CacheData.put("com.fangjia.job.fsh.po.Enterprise.enterprise_person_email", "enterprisePersonEmail");
|
||||
CacheData.put("com.fangjia.job.fsh.po.Enterprise.product_name", "productName");
|
||||
CacheData.put("com.fangjia.job.fsh.po.Enterprise.product_type", "productType");
|
||||
CacheData.put("com.fangjia.job.fsh.po.Enterprise.status", "status");
|
||||
CacheData.put("com.fangjia.job.fsh.po.Enterprise.sales_person", "salesPerson");
|
||||
CacheData.put("com.fangjia.job.fsh.po.Enterprise.sales_mobile", "salesMobile");
|
||||
CacheData.put("com.fangjia.job.fsh.po.Enterprise.open_status", "openStatus");
|
||||
CacheData.put("com.fangjia.job.fsh.po.Enterprise.open_date", "openDate");
|
||||
CacheData.put("com.fangjia.job.fsh.po.Enterprise.start_date", "startDate");
|
||||
CacheData.put("com.fangjia.job.fsh.po.Enterprise.end_date", "endDate");
|
||||
CacheData.put("com.fangjia.job.fsh.po.Enterprise.add_date", "addDate");
|
||||
CacheData.put("com.fangjia.job.fsh.po.Enterprise.modify_date", "modifyDate");
|
||||
CacheData.put("com.fangjia.job.fsh.po.Enterprise.remarks", "remarks");
|
||||
CacheData.put("com.fangjia.job.fsh.po.EnterpriseProductUser.uid", "uid");
|
||||
CacheData.put("com.fangjia.job.fsh.po.EnterpriseProductUser.eid", "eid");
|
||||
CacheData.put("com.fangjia.job.fsh.po.EnterpriseProductUser.add_time", "addTime");
|
||||
CacheData.put("com.fangjia.job.fsh.po.EnterpriseProductUser.remarks", "remarks");
|
||||
CacheData.put("com.fangjia.job.fsh.po.EnterpriseProductUser.city", "city");
|
||||
CacheData.put("com.fangjia.job.fsh.po.EnterpriseProductUser.region", "region");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.id", "id");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.city", "city");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.region", "region");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.name", "name");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.address", "address");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.lng", "lng");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.lat", "lat");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.estate_type", "estatetype");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.house_num", "houseNum");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.room_num", "roomNum");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.floor", "floor");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.height", "height");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.area", "area");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.room_count", "roomCount");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.hall_count", "hallCount");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.rent", "rent");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.purchase_date", "purchaseDate");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.purchase_price", "purchasePrice");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.price", "price");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.total_price", "totalPrice");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.eval_date", "evalDate");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.add_date", "addDate");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.live_status", "liveStatus");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.remove_status", "removeStatus");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.uid", "uid");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.eid", "eid");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.level", "level");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.growth_rate", "growthRate");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.appreciation", "appreciation");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.rose_ranking", "roseRanking");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.avgprice_ranking", "avgpriceRanking");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.rental_ratio", "rentalRatio");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.max_loan_money", "maxloanMoney");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.tag", "tag");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.liquidity_rating", "liquidityRating");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.one_year_total_price", "oneYearTotalPrice");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.house_room_num", "houseRoomNum");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.lease_start_date", "leaseStartDate");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.lease_end_date", "leaseEndDate");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.rent_cycle", "rentCycle");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.rent_cycle_unit", "rentCycleUnit");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.last_rent_date", "lastRentDate");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.min_sell_price", "minSellPrice");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.max_sell_price", "maxSellPrice");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.total_score", "totalScore");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.min_advice_value", "minAdviceValue");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseInfo.max_advice_value", "maxAdviceValue");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseSubstitution.id", "id");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseSubstitution.house_id", "houseId");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseSubstitution.substitution_type", "substitutionType");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseSubstitution.cur_money", "curMoney");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseSubstitution.budget", "budget");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseSubstitution.shoufu", "shoufu");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseSubstitution.intention_district", "intentionDistrict");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseSubstitution.reason", "reason");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseSubstitution.intention_area", "intentionArea");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseSubstitution.intention_city", "intentionCity");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseSubstitution.intention_region", "intentionRegion");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseSubstitution.intention_tags", "intentionTags");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseSubstitution.uid", "uid");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseSubstitution.eid", "eid");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseSubstitution.add_time", "addTime");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseSubstitution.match_count", "matchCount");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseSubstitution.dis_click_count", "disClickCount");
|
||||
CacheData.put("com.fangjia.job.fsh.po.HouseSubstitution.tax_rate", "taxRate");
|
||||
CacheData.put("com.fangjia.job.fsh.po.LoanApply.id", "id");
|
||||
CacheData.put("com.fangjia.job.fsh.po.LoanApply.type", "type");
|
||||
CacheData.put("com.fangjia.job.fsh.po.LoanApply.eid", "eid");
|
||||
CacheData.put("com.fangjia.job.fsh.po.LoanApply.uid", "uid");
|
||||
CacheData.put("com.fangjia.job.fsh.po.LoanApply.eval_money", "evalMoney");
|
||||
CacheData.put("com.fangjia.job.fsh.po.LoanApply.city", "city");
|
||||
CacheData.put("com.fangjia.job.fsh.po.LoanApply.apply_money", "applyMoney");
|
||||
CacheData.put("com.fangjia.job.fsh.po.LoanApply.mortgage", "mortgage");
|
||||
CacheData.put("com.fangjia.job.fsh.po.LoanApply.hid", "hid");
|
||||
CacheData.put("com.fangjia.job.fsh.po.LoanApply.add_time", "addTime");
|
||||
CacheData.put("com.fangjia.job.fsh.po.LoanApply.purpose", "purpose");
|
||||
CacheData.put("com.fangjia.job.fsh.po.LoanApply.work", "work");
|
||||
CacheData.put("com.fangjia.job.fsh.po.LoanApply.wages", "wages");
|
||||
CacheData.put("com.fangjia.job.fsh.po.LoanApply.assets", "assets");
|
||||
CacheData.put("com.fangjia.job.fsh.po.LoanApply.credit", "credit");
|
||||
CacheData.put("com.fangjia.job.fsh.po.VisitLog.id", "id");
|
||||
CacheData.put("com.fangjia.job.fsh.po.VisitLog.uri", "uri");
|
||||
CacheData.put("com.fangjia.job.fsh.po.VisitLog.page", "page");
|
||||
CacheData.put("com.fangjia.job.fsh.po.VisitLog.visit_time", "visitTime");
|
||||
CacheData.put("com.fangjia.job.fsh.po.VisitLog.eid", "eid");
|
||||
CacheData.put("com.fangjia.job.fsh.po.VisitLog.uid", "uid");
|
||||
CacheData.put("com.fangjia.job.fsh.po.VisitLog.ip", "ip");
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.fangjia.job.fsh.handler;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.dangdang.ddframe.job.executor.handler.JobExceptionHandler;
|
||||
import com.fangjia.job.common.util.DingDingMessageUtil;
|
||||
|
||||
/**
|
||||
* 自定义异常处理,在任务异常时使用钉钉发送通知
|
||||
* @author yinjihuan
|
||||
*/
|
||||
public class CustomJobExceptionHandler implements JobExceptionHandler {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(CustomJobExceptionHandler.class);
|
||||
|
||||
@Override
|
||||
public void handleException(String jobName, Throwable cause) {
|
||||
logger.error(String.format("Job '%s' exception occur in job processing", jobName), cause);
|
||||
DingDingMessageUtil.sendTextMessage("【"+jobName+"】任务异常。" + cause.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -43,7 +43,7 @@
|
||||
<job:simple id="enterpriseStatJob" class="com.fangjia.job.fsh.job.EnterpriseStatJob" registry-center-ref="regCenter"
|
||||
sharding-total-count="1" cron="0 1 0 * * ?" sharding-item-parameters=""
|
||||
monitor-execution="false" failover="true" description="【房生活】企业统计任务,每天0点1分开始执行,主要统计企业相关的数据,统计内容参考 EnterpriseStat"
|
||||
disabled="false" overwrite="true" event-trace-rdb-data-source="elasticJobLog" >
|
||||
disabled="false" overwrite="true" event-trace-rdb-data-source="elasticJobLog" job-exception-handler="com.fangjia.job.fsh.handler.CustomJobExceptionHandler">
|
||||
|
||||
<job:listener class="com.fangjia.job.fsh.listener.MessageElasticJobListener"></job:listener>
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
<job:simple id="userStatJob" class="com.fangjia.job.fsh.job.UserStatJob" registry-center-ref="regCenter"
|
||||
sharding-total-count="1" cron="0 10 1 * * ?" sharding-item-parameters=""
|
||||
monitor-execution="false" failover="true" description="【房生活】用户维度统计任务,统计出用户的房产,置换,贷款等信息 UserStatJob"
|
||||
disabled="false" overwrite="true" event-trace-rdb-data-source="elasticJobLog" >
|
||||
disabled="false" overwrite="true" event-trace-rdb-data-source="elasticJobLog" job-exception-handler="com.fangjia.job.fsh.handler.CustomJobExceptionHandler">
|
||||
|
||||
<job:listener class="com.fangjia.job.fsh.listener.MessageElasticJobListener"></job:listener>
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
<job:simple id="houseRoseMonthNoticeJob" class="com.fangjia.job.fsh.job.HouseRoseMonthNoticeJob" registry-center-ref="regCenter"
|
||||
sharding-total-count="1" cron="0 10 1 1 * ?" sharding-item-parameters=""
|
||||
monitor-execution="false" failover="true" description="【房生活】房产月涨幅通知任务, 每个月1号触发,目前计算逻辑在服务端"
|
||||
disabled="false" overwrite="true" event-trace-rdb-data-source="elasticJobLog" >
|
||||
disabled="false" overwrite="true" event-trace-rdb-data-source="elasticJobLog" job-exception-handler="com.fangjia.job.fsh.handler.CustomJobExceptionHandler">
|
||||
|
||||
<job:listener class="com.fangjia.job.fsh.listener.MessageElasticJobListener"></job:listener>
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
<job:simple id="houseRentNoticeJob" class="com.fangjia.job.fsh.job.HouseRentNoticeJob" registry-center-ref="regCenter"
|
||||
sharding-total-count="1" cron="0 10 2 * * ?" sharding-item-parameters=""
|
||||
monitor-execution="false" failover="true" description="【房生活】房产租金提醒任务,每天触发一次,逻辑在服务端"
|
||||
disabled="false" overwrite="true" event-trace-rdb-data-source="elasticJobLog" >
|
||||
disabled="false" overwrite="true" event-trace-rdb-data-source="elasticJobLog" job-exception-handler="com.fangjia.job.fsh.handler.CustomJobExceptionHandler">
|
||||
|
||||
<job:listener class="com.fangjia.job.fsh.listener.MessageElasticJobListener"></job:listener>
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
<job:simple id="houseWeekEvalJob" class="com.fangjia.job.fsh.job.HouseWeekEvalJob" registry-center-ref="regCenter"
|
||||
sharding-total-count="1" cron="0 10 2 ? * 2" sharding-item-parameters=""
|
||||
monitor-execution="false" failover="true" description="【房生活】房产每周一定时估价任务,逻辑在服务端,同时需要算出周涨幅通知"
|
||||
disabled="false" overwrite="true" event-trace-rdb-data-source="elasticJobLog" >
|
||||
disabled="false" overwrite="true" event-trace-rdb-data-source="elasticJobLog" job-exception-handler="com.fangjia.job.fsh.handler.CustomJobExceptionHandler">
|
||||
|
||||
<job:listener class="com.fangjia.job.fsh.listener.MessageElasticJobListener"></job:listener>
|
||||
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@
|
||||
<commons-dbcp.version>1.4</commons-dbcp.version>
|
||||
<mysql.version>5.1.30</mysql.version>
|
||||
<maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
|
||||
<jdbc.version>1.0.0</jdbc.version>
|
||||
<jdbc.version>1.0.1</jdbc.version>
|
||||
<feign.version>9.5.0</feign.version>
|
||||
</properties>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user