Testing for IInterruptableJob

别来无恙 提交于 2019-12-31 04:59:08

问题


I have the following code:

    private static void InterruptAJob(JobKey foundJobKey, IScheduler sched)
    {
        if (null != foundJobKey)
        {
            sched.Interrupt(foundJobKey);
        }
    }

I get this exception (I expect this):

"Job 'groupName001.testJobDetailImpl_0' can not be interrupted, since it does not implement Quartz.IInterruptableJob"

Is there a way to test for IInterruptableJob using the "JobKey"?

........

EDIT (APPEND)

/// <summary>
/// Request the interruption, within this Scheduler instance, of all
/// currently executing instances of the identified <see cref="IJob" />, which
/// must be an implementor of the <see cref="IInterruptableJob"/> interface.
/// </summary>
/// <remarks>
/// <para>
/// If more than one instance of the identified job is currently executing,
/// the <see cref="IInterruptableJob.Interrupt"/> method will be called on
/// each instance. However, there is a limitation that in the case that
/// <see cref="Interrupt(JobKey)"/> on one instances throws an exception, all
/// remaining instances (that have not yet been interrupted) will not have
/// their <see cref="Interrupt(JobKey)"/> method called.
/// </para>
/// <para>
/// If you wish to interrupt a specific instance of a job (when more than
/// one is executing) you can do so by calling
/// <see cref="GetCurrentlyExecutingJobs"/> to obtain a handle
/// to the job instance, and then invoke <see cref="Interrupt(JobKey)"/> on it
/// yourself.
/// </para>
/// <para>
/// This method is not cluster aware. That is, it will only interrupt
/// instances of the identified InterruptableJob currently executing in this
/// Scheduler instance, not across the entire cluster.
/// </para>
/// </remarks>
/// <returns>true is at least one instance of the identified job was found and interrupted.</returns>
/// <throws> UnableToInterruptJobException if the job does not implement </throws>
/// <seealso cref="IInterruptableJob"/>
/// <seealso cref="GetCurrentlyExecutingJobs"/>
public virtual bool Interrupt(JobKey jobKey)
{

The comments say use IScheduler.GetCurrentlyExecutingJobs(). Which gives me a collection of JobKey's.

I guess another way to ask the question is... how I can get this below functionality?

IScheduler.GetCurrentlyExecutingIInterruptableJobs

来源:https://stackoverflow.com/questions/21537460/testing-for-iinterruptablejob

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!