Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

项目关闭时从last_instance_active_time HASH中移除本机 #59

Open
cyao2q opened this issue Jan 25, 2021 · 1 comment
Open

项目关闭时从last_instance_active_time HASH中移除本机 #59

cyao2q opened this issue Jan 25, 2021 · 1 comment

Comments

@cyao2q
Copy link

cyao2q commented Jan 25, 2021

No description provided.

@cyao2q
Copy link
Author

cyao2q commented Feb 22, 2021

package com.cyao.schedule.jobstore;

import net.joelinn.quartz.jobstore.RedisJobStoreSchema;
import org.quartz.JobPersistenceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 重写RedisJobStore的shutdown方法保证项目关闭时从redis清除当前instanceId
 *
 * @author Cyao
 */
public class RedisJobStore extends net.joelinn.quartz.jobstore.RedisJobStore {
    private Logger logger = LoggerFactory.getLogger(getClass());

    @Override
    public void shutdown() {
        logger.info("RedisJobStore_$_{} shutting down.", instanceId);
        final RedisJobStoreSchema redisSchema = new RedisJobStoreSchema(keyPrefix, keyDelimiter);
        try {
            super.doWithLock(jedis -> jedis.hdel(redisSchema.lastInstanceActiveTime(), instanceId));
        } catch (JobPersistenceException e) {
            e.printStackTrace();
        }
        super.shutdown();
        logger.info("RedisJobStore_$_{} shutdown complete.", instanceId);
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant