小编wal*_*len的帖子

部署后,Quartz.net调度程序不会触发作业/触发器

介绍

我使用Quartz.Net上的ASP.Net框架4,WebForms的网站.基本上,用户应该无法手动触发批处理脚本,该脚本异步处理存储在数据库中的数千条记录.用户可以随时停止或暂停,调整一些变量,并在需要时继续处理(剩余记录).
代码在本地完成并运行(开发人员机器,win7,vs2010,sql server express 2008 R2).
它还在本地服务器上进行了测试(win server 2008 R2,sql server express 2008 R2).它在两个环境中都能正常工作,并使用预编译的所有代码进行测试.问题是,一旦部署在远程服务器(win server 2008 R2)上,它实际上应该在其上运行(托管环境,不共享,不集群),它并不完全有效(详情见​​下文).调度程序已创建,但触发器(即作业)不会触发.

(注意:我知道有些人会建议使用Quartz作为Windows服务,但尽管有这样做的好处,我真的想知道为什么它不能用作嵌入式解决方案,因为它应该工作得很好喜欢本地)

细节

Quartz 2.1.2  
Common.Logging 2.1.2  
Common.Logging.NLog 2.0.0  
NLog 2.0.1.2
Run Code Online (Sandbox Code Playgroud)

Global.asax中

public static ISchedulerFactory SchedulerFactory;
public static IScheduler Scheduler;

void Application_Start(object sender, EventArgs e)
{
    SchedulerFactory = new StdSchedulerFactory();
    Scheduler = SchedulerFactory.GetScheduler();

    // Define a durable job instance (durable jobs can exist without triggers)
    IJobDetail job = JobBuilder.Create<MyJobClass>()
                                .WithIdentity("MyJob", "MyGroup")
                                .StoreDurably()
                                .Build(); …
Run Code Online (Sandbox Code Playgroud)

asp.net quartz.net

9
推荐指数
2
解决办法
1万
查看次数

同一个Job Quartz.Net的多个触发器

我有以下代码:

 IScheduler scheduler = StdSchedulerFactory.GetDefaultScheduler();
            scheduler.Start();
            IJobDetail job = JobBuilder.Create<EmailJob>().StoreDurably().WithIdentity("J_Email", "J_Mailing").Build();         
            ITrigger trigger = TriggerBuilder.Create()
                                .WithIdentity("MailTrigger1", "T_Mail1")
                                .StartNow()                                
                                .WithSimpleSchedule(x => x.WithMisfireHandlingInstructionIgnoreMisfires()
                                    .WithIntervalInSeconds(3)
                                    .RepeatForever())
                                .Build();       


            ITrigger triggernew = TriggerBuilder.Create()
                               .WithIdentity("MailTrigger", "T_Mail")
                               .StartNow()                               
                               .WithSimpleSchedule(x => x.WithMisfireHandlingInstructionIgnoreMisfires()
                                   .WithIntervalInSeconds(5)
                                   .RepeatForever())
                               .Build();        
            scheduler.ScheduleJob(job,triggernew);
            scheduler.ScheduleJob(job,trigger);
Run Code Online (Sandbox Code Playgroud)

我收到以下异常:

Quartz.dll中发生了未处理的"Quartz.ObjectAlreadyExistsException"类型异常

附加信息:无法存储作业:'J_Mailing.J_Email',因为已存在此标识.

但我被告知你可以拥有同一个JOB的多个触发器.也许我做错了什么?

quartz.net

8
推荐指数
1
解决办法
6355
查看次数

划分边框图像

有什么好方法可以设置一个容器div,周围有一些边框图像(在我的情况下只在左侧,底部和右侧)?我把它放在页面顶部,重叠其他所有内容(就像那个OSX风格的下拉式对话框一样).

这是基本布局:

替代文字

这是我到目前为止所得到的内容(我可以避免内容的静态宽度/高度吗?):

HTML:

<div class="contentbox">
    <div class="contentbox-wrapper" style="width: 400px">
        <div class="contentbox-mid" style="height: 200px">
            <div class="contentbox-w"></div>
            <div class="contentbox-content">
                Content Box Test
            </div>
            <div class="contentbox-e"></div>
        </div>
        <div class="contentbox-bottom">
            <div class="contentbox-sw"></div>
            <div class="contentbox-s"></div>
            <div class="contentbox-se"></div>
        </div>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS:

.contentbox {
    width: 100%;
    position: fixed;
    z-index: 2;
}

.contentbox-wrapper {
    width: 300px;
    margin-left: auto;
    margin-right: auto;
}

.contentbox-mid {
    height: 100px;
}

.contentbox-w {
    width: 30px;
    height: 100%;
    background: transparent url("../../images/contentbox_w.png");
    float: left;
}

.contentbox-content {
    width: auto;
    height: 100%;
    background: #e8e8e8; …
Run Code Online (Sandbox Code Playgroud)

html css

7
推荐指数
2
解决办法
2万
查看次数

IServiceCollection 不包含 AddQuartz 的定义

我正在尝试在我的 asp core 2.0 项目中使用 Quartz sheduker。我使用 nuget 下载了 Quartz 3.0.4,之后添加了 services.AddQuartz(new QuartezOptions {}); Startup.cs中的ConfigureService函数

我对 app.UseQuartz() 也有同样的问题

这就是 Startup.cs 现在的样子:

using AspProj.Map;
using Microsoft.Extensions.Configuration;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Swashbuckle.AspNetCore.Swagger;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Quartz;



namespace AspProj
{
    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

    public IConfiguration Configuration { get; }

    // This method gets called by the runtime. Use this method to add services to the container.
    public …
Run Code Online (Sandbox Code Playgroud)

c# quartz.net asp.net-core-mvc quartz asp.net-core-2.0

7
推荐指数
1
解决办法
3123
查看次数

jdk.serialFilter 不能用于限制 Java 中 TreeMap 的深度(防止通过 Java 进行 DoS 攻击)

如何通过 Java 防止 DoS 攻击TreeMap

我的代码有一个接受Map对象的 API 。现在我想阻止客户端发送Map一定长度的对象。

现在maxarrayinjdk.serialFilter能够阻止客户端发送HashMap大小 >的对象maxarray

我也想这样做TreeMap。但是maxarrayfield 对TreeMap. 它无法拒绝该请求。

我也设置了maxdepth尺寸。但没有任何效果。

任何人都可以帮我解决这个问题吗?

java security denial-of-service treemap deserialization

7
推荐指数
2
解决办法
328
查看次数

来自asp.net中的config xml的quartz.net

有人可以告诉我我做错了什么.我正在尝试设置qurtz,以便在启动时它将读取xml配置文件.在文件中有一个激活我的HelloEmail_Job.cs类的作业(它被正确创建,使用execute方法中的逻辑扩展IJob).xml还有一个cron触发器,用于每分钟触发的作业(纯粹用于测试)

但一切都没有错误地启动,但工作永远不会发生.我确信我配置错误

我有一个处理我的调度程序生成的单例,调度程序在我的应用程序启动时启动(在global.asax文件中)

    NameValueCollection properties = new NameValueCollection();
    properties["quartz.scheduler.instanceName"] = "RemoteServer";

    ////// set thread pool info
    properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz";
    properties["quartz.threadPool.threadCount"] = "5";
    properties["quartz.threadPool.threadPriority"] = "Normal";

    properties["quartz.jobStore.type"] = "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz";
    properties["quartz.jobStore.useProperties"] = "true";
    properties["quartz.jobStore.dataSource"] = "default";
    properties["quartz.jobStore.tablePrefix"] = "QRTZ_";
    properties["quartz.jobStore.lockHandler.type"] = "Quartz.Impl.AdoJobStore.UpdateLockRowSemaphore, Quartz";

    properties["quartz.dataSource.default.connectionString"] = "Data Source=CRAIG-PC\\SQLEXPRESS;Initial Catalog=MCWdb;User ID=sa;Password=mastercrud;";
    properties["quartz.dataSource.default.provider"] = "SqlServer-20";

    // job initialization plugin handles our xml reading, without it defaults are used
    properties["quartz.plugin.xml.type"] = "Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin, Quartz";
    properties["quartz.plugin.xml.fileNames"] = "~/quartz_jobs.xml";

    ISchedulerFactory sf = new StdSchedulerFactory(properties);
    _sched = sf.GetScheduler(); …
Run Code Online (Sandbox Code Playgroud)

asp.net quartz.net

5
推荐指数
1
解决办法
5579
查看次数

我如何在Quartz.Net中的父作业中等待完成子作业

我有一个容器(父)工作.它包含儿童工作.完成所有childJobs后,将完成ParentJob.问题在代码中.

public class ParentJob : InterruptableJob
{
    private childrenAreCompleted = false;
    private ChildJobListener _listener;

    public override void Execute(IJobExecutionContext context)
    {
        var childs = new int[] { 1, 2, 3 };

        _listener = new ChildJobListener(childs.Length);
        _listener.OnCompleted += new Action(_listener_OnCompleted);

        JobKey jk = typeof(ChildJob).JobKey(); // My Type extension :)
        IMatcher<JobKey> matcher = KeyMatcher<JobKey>.KeyEquals(jk);// this is wrong because ParentJob could be called concurrently. 

        context.Scheduler.ListenerManager.AddJobListener(_listener, matcher);


        foreach (var child in childs)
        {
            JobDataMap jobData = new JobDataMap();
            jobData.Add("ParentId", context.FireInstanceId);//TODO: suspected I want to use …
Run Code Online (Sandbox Code Playgroud)

c# quartz.net

5
推荐指数
1
解决办法
1021
查看次数

如何在Idea中复制当前行号?

有人知道如何在Intellij Idea 11中复制当前行号吗?

intellij-idea

5
推荐指数
2
解决办法
2477
查看次数

如何在我的代码中找到所有未关闭的实例和对象?

我的团队有相当多的代码。最近我发现了一些没有正确关闭的对象。
如何找到所有未关闭或不在try-with-resources块内的实例?
一些对象,例如Statement,ResultSet甚至没有显示警告消息。

是否有用于显示所有这些事件的扩展工具?
我正在使用 Eclipse。

java try-with-resources autocloseable

5
推荐指数
1
解决办法
670
查看次数

Quartz.Net TriggerJob并等待执行

我需要手动调用一些 Quartz.NET 作业并等待它们完成。请参阅下面的简化示例代码:

[HttpPost("[action]/{jobKey}")]
public async Task<IActionResult> StartJob(string jobKey)
{
    await _schedulerService.Scheduler.TriggerJob(new Quartz.JobKey(jobKey)); 
    return Ok();
}
Run Code Online (Sandbox Code Playgroud)

但是,使用 TriggerJob 也不会等待作业本身的执行完成。使用 Quartz.NET 可以实现这一点吗?我在 .NET Core 上使用它,并使用以下包:

 <PackageReference Include="Quartz" Version="3.0.7" />
Run Code Online (Sandbox Code Playgroud)

.net quartz.net quartz quartz.net-3.0

5
推荐指数
0
解决办法
424
查看次数