All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.hengboy.job.schedule.runnable.MicroJobConsumerJobKeySyncRunnable Maven / Gradle / Ivy

The newest version!
/*
 *    Copyright [2019] [恒宇少年 - 于起宇]
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package com.github.hengboy.job.schedule.runnable;

import com.github.hengboy.job.core.http.MicroJobRestTemplate;
import com.github.hengboy.job.core.http.RestUrlConstants;
import com.github.hengboy.job.core.http.RestUrlTools;
import com.github.hengboy.job.core.http.model.request.JobKeys;
import com.github.hengboy.job.schedule.resource.MicroJobScheduleResource;
import com.github.hengboy.job.schedule.store.model.JobDetail;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpHeaders;

/**
 * 同步消费者定义的jobKey
 *
 * @author:恒宇少年 - 于起宇
 * 

* DateTime:2019-02-20 16:41 * Blog:http://blog.yuqiyu.com * WebSite:http://www.jianshu.com/u/092df3f77bca * Gitee:https://gitee.com/hengboy * GitHub:https://github.com/hengyuboy */ public class MicroJobConsumerJobKeySyncRunnable implements Runnable { /** * logger instance */ static Logger logger = LoggerFactory.getLogger(MicroJobConsumerJobKeySyncRunnable.class); @Override public void run() { try { MicroJobRestTemplate restTemplate = MicroJobScheduleResource.getRestTemplate(); // 格式化心跳检查http路径 String syncDefineJobKeyUrl = RestUrlTools.formatter(MicroJobScheduleResource.getRegistryIpAddress(), MicroJobScheduleResource.getRegistryPort(), RestUrlConstants.REGISTRY_JOB_KEY_GET_ALL_FULL_URL); // 发送同步jobKey定义 JobKeys jobKeys = restTemplate.getForObject(syncDefineJobKeyUrl, HttpHeaders.EMPTY, JobKeys.class); // 缓存消费者定义jobKey jobKeys.getJobKeys().stream().forEach(jobKey -> { JobDetail jobDetail = new JobDetail(); jobDetail.setMjdJobKey(jobKey); MicroJobScheduleResource.getCONSUMER_JOBS().put(jobKey, jobDetail); }); } catch (Exception e) { logger.error("Mission registry heart rate check failed", e); } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy