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

Sqlserver backed recenthistory #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 115 additions & 0 deletions Database/Tables/tables_sqlServer.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
USE [enter_db_name_here]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[DF_QRTZ_EXECUTION_HISTORY_VETOED]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[QRTZ_EXECUTION_HISTORY_ENTRIES] DROP CONSTRAINT [DF_QRTZ_EXECUTION_HISTORY_VETOED]
END
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[DF_QRTZ_EXECUTION_HISTORY_RECOVERING]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[QRTZ_EXECUTION_HISTORY_ENTRIES] DROP CONSTRAINT [DF_QRTZ_EXECUTION_HISTORY_RECOVERING]
END
GO
IF EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[QRTZ_EXECUTION_HISTORY_ENTRIES]') AND name = N'IX_TRIGGER_NAME_ACTUAL_FIRE_TIME_UTC')
DROP INDEX [IX_TRIGGER_NAME_ACTUAL_FIRE_TIME_UTC] ON [dbo].[QRTZ_EXECUTION_HISTORY_ENTRIES]
GO
IF EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[QRTZ_EXECUTION_HISTORY_ENTRIES]') AND name = N'IX_SCHED_NAME')
DROP INDEX [IX_SCHED_NAME] ON [dbo].[QRTZ_EXECUTION_HISTORY_ENTRIES]
GO
IF EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[QRTZ_EXECUTION_HISTORY_ENTRIES]') AND name = N'IX_JOB_NAME_ACTUAL_FIRE_TIME_UTC')
DROP INDEX [IX_JOB_NAME_ACTUAL_FIRE_TIME_UTC] ON [dbo].[QRTZ_EXECUTION_HISTORY_ENTRIES]
GO
IF EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[QRTZ_EXECUTION_HISTORY_ENTRIES]') AND name = N'IX_ACTUAL_FIRE_TIME_UTC')
DROP INDEX [IX_ACTUAL_FIRE_TIME_UTC] ON [dbo].[QRTZ_EXECUTION_HISTORY_ENTRIES]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[QRTZ_EXECUTION_HISTORY_STATS]') AND type in (N'U'))
DROP TABLE [dbo].[QRTZ_EXECUTION_HISTORY_STATS]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[QRTZ_EXECUTION_HISTORY_ENTRIES]') AND type in (N'U'))
DROP TABLE [dbo].[QRTZ_EXECUTION_HISTORY_ENTRIES]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[QRTZ_EXECUTION_HISTORY_ENTRIES]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[QRTZ_EXECUTION_HISTORY_ENTRIES](
[FIRE_INSTANCE_ID] [nvarchar](140) NOT NULL,
[SCHEDULER_INSTANCE_ID] [nvarchar](200) NOT NULL,
[SCHED_NAME] [nvarchar](120) NOT NULL,
[JOB_NAME] [nvarchar](150) NOT NULL,
[TRIGGER_NAME] [nvarchar](150) NOT NULL,
[SCHEDULED_FIRE_TIME_UTC] [datetime] NULL,
[ACTUAL_FIRE_TIME_UTC] [datetime] NOT NULL,
[RECOVERING] [bit] NOT NULL,
[VETOED] [bit] NOT NULL,
[FINISHED_TIME_UTC] [datetime] NULL,
[EXCEPTION_MESSAGE] [nvarchar](max) NULL,
CONSTRAINT [PK_QRTZ_EXECUTION_HISTORY_ENTRIES] PRIMARY KEY CLUSTERED
(
[FIRE_INSTANCE_ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[QRTZ_EXECUTION_HISTORY_STATS]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[QRTZ_EXECUTION_HISTORY_STATS](
[SCHED_NAME] [nvarchar](120) NOT NULL,
[STAT_NAME] [nvarchar](120) NOT NULL,
[STAT_VALUE] [bigint] NULL,
CONSTRAINT [PK_EXECUTION_HISTORY_STATS] PRIMARY KEY CLUSTERED
(
[SCHED_NAME] ASC,
[STAT_NAME] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[QRTZ_EXECUTION_HISTORY_ENTRIES]') AND name = N'IX_ACTUAL_FIRE_TIME_UTC')
CREATE NONCLUSTERED INDEX [IX_ACTUAL_FIRE_TIME_UTC] ON [dbo].[QRTZ_EXECUTION_HISTORY_ENTRIES]
(
[ACTUAL_FIRE_TIME_UTC] DESC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[QRTZ_EXECUTION_HISTORY_ENTRIES]') AND name = N'IX_JOB_NAME_ACTUAL_FIRE_TIME_UTC')
CREATE NONCLUSTERED INDEX [IX_JOB_NAME_ACTUAL_FIRE_TIME_UTC] ON [dbo].[QRTZ_EXECUTION_HISTORY_ENTRIES]
(
[JOB_NAME] ASC,
[ACTUAL_FIRE_TIME_UTC] DESC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[QRTZ_EXECUTION_HISTORY_ENTRIES]') AND name = N'IX_SCHED_NAME')
CREATE NONCLUSTERED INDEX [IX_SCHED_NAME] ON [dbo].[QRTZ_EXECUTION_HISTORY_ENTRIES]
(
[SCHED_NAME] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[QRTZ_EXECUTION_HISTORY_ENTRIES]') AND name = N'IX_TRIGGER_NAME_ACTUAL_FIRE_TIME_UTC')
CREATE NONCLUSTERED INDEX [IX_TRIGGER_NAME_ACTUAL_FIRE_TIME_UTC] ON [dbo].[QRTZ_EXECUTION_HISTORY_ENTRIES]
(
[TRIGGER_NAME] ASC,
[ACTUAL_FIRE_TIME_UTC] DESC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[DF_QRTZ_EXECUTION_HISTORY_RECOVERING]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[QRTZ_EXECUTION_HISTORY_ENTRIES] ADD CONSTRAINT [DF_QRTZ_EXECUTION_HISTORY_RECOVERING] DEFAULT ((0)) FOR [RECOVERING]
END
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[DF_QRTZ_EXECUTION_HISTORY_VETOED]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[QRTZ_EXECUTION_HISTORY_ENTRIES] ADD CONSTRAINT [DF_QRTZ_EXECUTION_HISTORY_VETOED] DEFAULT ((0)) FOR [VETOED]
END
GO
43 changes: 7 additions & 36 deletions Quartzmin.sln
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetCoreSelfHost", "Source\E
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinFormSelfHost", "Source\Examples\WinFormSelfHost\WinFormSelfHost.csproj", "{C54F4403-F40A-497C-B3A7-D1F1E1830D52}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNetCoreDocker", "Source\Examples\AspNetCoreDocker\AspNetCoreDocker.csproj", "{68D816F2-21BF-4376-ABF4-70390E4783C5}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNetCoreDocker", "Source\Examples\AspNetCoreDocker\AspNetCoreDocker.csproj", "{68D816F2-21BF-4376-ABF4-70390E4783C5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Quartz.Plugins.RecentHistory.Tests.Integration", "Source\Quartz.Plugins.RecentHistory.Tests.Integration\Quartz.Plugins.RecentHistory.Tests.Integration.csproj", "{3FC7A772-C5E2-4DAD-B3F2-D2D6894858D5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -59,6 +61,10 @@ Global
{68D816F2-21BF-4376-ABF4-70390E4783C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{68D816F2-21BF-4376-ABF4-70390E4783C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{68D816F2-21BF-4376-ABF4-70390E4783C5}.Release|Any CPU.Build.0 = Release|Any CPU
{3FC7A772-C5E2-4DAD-B3F2-D2D6894858D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3FC7A772-C5E2-4DAD-B3F2-D2D6894858D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3FC7A772-C5E2-4DAD-B3F2-D2D6894858D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3FC7A772-C5E2-4DAD-B3F2-D2D6894858D5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -73,39 +79,4 @@ Global
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0357313D-BD09-4C5D-AF0D-439B3BD33B5A}
EndGlobalSection
GlobalSection(TeamFoundationVersionControl) = preSolution
SccNumberOfProjects = 9
SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
SccTeamFoundationServer = http://tfs/defaultcollection
SccLocalPath0 = .
SccProjectUniqueName1 = Source\\Quartzmin\\Quartzmin.csproj
SccProjectName1 = Source/Quartzmin
SccLocalPath1 = Source\\Quartzmin
SccProjectUniqueName2 = Source\\Quartz.Plugins.RecentHistory\\Quartz.Plugins.RecentHistory.csproj
SccProjectName2 = Source/Quartz.Plugins.RecentHistory
SccLocalPath2 = Source\\Quartz.Plugins.RecentHistory
SccProjectUniqueName3 = Source\\Quartzmin.SelfHost\\Quartzmin.SelfHost.csproj
SccProjectName3 = Source/Quartzmin.SelfHost
SccLocalPath3 = Source\\Quartzmin.SelfHost
SccProjectUniqueName4 = Source\\Examples\\NetCoreSelfHost\\NetCoreSelfHost.csproj
SccProjectTopLevelParentUniqueName4 = Quartzmin.sln
SccProjectName4 = Source/Examples/NetCoreSelfHost
SccLocalPath4 = Source\\Examples\\NetCoreSelfHost
SccProjectUniqueName5 = Source\\Examples\\AspNetCoreHost\\AspNetCoreHost.csproj
SccProjectTopLevelParentUniqueName5 = Quartzmin.sln
SccProjectName5 = Source/Examples/AspNetCoreHost
SccLocalPath5 = Source\\Examples\\AspNetCoreHost
SccProjectUniqueName6 = Source\\Examples\\AspNetWebHost\\AspNetWebHost.csproj
SccProjectTopLevelParentUniqueName6 = Quartzmin.sln
SccProjectName6 = Source/Examples/AspNetWebHost
SccLocalPath6 = Source\\Examples\\AspNetWebHost
SccProjectUniqueName7 = Source\\Examples\\WinFormSelfHost\\WinFormSelfHost.csproj
SccProjectTopLevelParentUniqueName7 = Quartzmin.sln
SccProjectName7 = Source/Examples/WinFormSelfHost
SccLocalPath7 = Source\\Examples\\WinFormSelfHost
SccProjectUniqueName8 = Source\\Examples\\AspNetCoreDocker\\AspNetCoreDocker.csproj
SccProjectTopLevelParentUniqueName8 = Quartzmin.sln
SccProjectName8 = Source/Examples/AspNetCoreDocker
SccLocalPath8 = Source\\Examples\\AspNetCoreDocker
EndGlobalSection
EndGlobal
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,29 @@ public void Configure(IApplicationBuilder app)
}
```

### SQL server recent job history persistence
Execute the SQL server deployment script from the `/Database` folder of this repo in a database of your choosing.

Add `SqlServerExecutionHistoryPlugin` specific settings to your `App.config` file:
```xml
<configuration>
<configSections>
<section name="quartz" type="System.Configuration.NameValueFileSectionHandler" />
</configSections>

<quartz>
<add key="quartz.plugin.quartzmin.type" value="Quartzmin.SelfHost.QuartzminPlugin, Quartzmin.SelfHost" />
<add key="quartz.plugin.quartzmin.url" value="http://localhost:5000" />

<add key="quartz.plugin.recentHistory.type" value="Quartz.Plugins.RecentHistory.Impl.SqlServer.SqlServerExecutionHistoryPlugin, Quartz.Plugins.RecentHistory" />
<add key="quartz.plugin.recentHistory.connectionString" value="Server=.\SQLEXPRESS;Database=Scheduler;Trusted_Connection=True;" />
<add key="quartz.plugin.recentHistory.entryTTLInMinutes" value="60" />
<add key="quartz.plugin.recentHistory.tablePrefix" value="QRTZ_" />
</quartz>
</configuration>
```


## Notes
In clustered environment, it make more sense to host Quarzmin on single dedicated Quartz.NET node in standby mode and implement own `IExecutionHistoryStore` depending on database or ORM framework you typically incorporate. Every clustered Quarz.NET node should be configured with `ExecutionHistoryPlugin` and only dedicated node for management may have `QuartzminPlugin`.

Expand Down
Loading