SharePoint:Timerjobs 锁定类型

发布于 2024-08-02 16:35:55 字数 957 浏览 6 评论 0原文

我正在尝试在 WSS 3.0 中创建计时器作业。我的计时器作业将使用存储在任何 xml 或数据库中的 GUID 创建 SPsite、SPWeb 和 SPDocumentLibrary(或可能是图片库)的对象。之后,它将在某些第三方应用程序中备份文档库中的文档,并然后删除这些文件。

所以我的问题是:理想情况下我的 SPJobLockType 'None' 或 'Job' 或 'ContentDatabase' 应该是什么?以下是我在阅读一些有关计时器作业的文章后的理解。如果我在任何地方出错,请纠正我,因为我对 SharePoint 还很陌生

  1. 如果我使用“无”,那么我的作业将在场中的每台服务器上运行。我真的需要那个吗?因为我的工作只是修改/删除文档(我通过计时器作业仅修改内容数据库。如果我错了,请纠正我)。

  2. 如果我使用锁定类型“Job”,那么我的作业将仅在执行作业创建代码的服务器上运行。但它可以满足我的要求(我认为是这样,但我不确定如果错误请纠正我) )。

  3. 我已经浏览了这篇针对ContentDatabase LockType的文章..它说

简而言之,和上面的几乎一样 作业一,意味着它只运行一个 服务器..但是..正如彼得发现的那样 需要有关自定义计时器作业的帮助 SharePoint 2007,作业运行时间为 每个内容数据库 WebApplication 与之关联。 另一个(相当烦人的)事实是 当它发生时,这是不可预测的 将在下一个内容数据库上运行。

请给出您的想法/建议。

I am trying to create a timer job in WSS 3.0. My timer job would create the object of SPsite then SPWeb and then SPDocumentLibrary (or possibly picture library)using their GUIDs stored in any xml or database.After that it would take the back up of documents in the document library in some third party application and then delete those documents.

So my question is: what should be my SPJobLockType 'None' or 'Job' or 'ContentDatabase' ideally?? Following is my understanding after reading some articles on timer job. Please correct me if I am wrong at any place as I am quite new to SharePoint

  1. If i use 'None', then my job would run on each server in the farm. Do I really need that? because my job is only modifying /deleting documents(I am modifing only content database through my timer job. Please correct me if I am wrong).

  2. If I use lock type 'Job' , then my job would run only on the server on which job creation code is executed.But it can fulfil my requirement(I think so but i am not sure please correct me if am wrong ).

  3. I have gone through this article for ContentDatabase LockType..It says

in short, it’s almost the same as the
Job one, meaning that it only runs one
server.. BUT.. as Peter find out at
Help needed with custom timerjob in
SharePoint 2007 , the job runs for
each ContentDatabase that the
WebApplication is associated with.
Another (quite annoying) fact is that
it is not that predictable when it
will run on the next content database.

Please give your thoughts/Suggestions.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷爱 2024-08-09 16:35:55

Anoop,

您所描述的“扫描”类型的计时器工作是一种相当常见的工作,我自己为不同的项目编写了其中的一些工作。在这种类型的计时器作业中,您正在处理一组站点、网络或列表以执行某种维护。一次处理一个站点/网站/列表通常是最简单的,并且正在执行的任务不是需要以最大速度执行的类型(也就是说,需要并发/多线程处理模型来执行)快速完成)。

在这种类型的场景中,我通常构建计时器作业以使用“Job”的 SPJobLockType。正如您所指出的,这可确保场内任何给定时间只有一个计时器作业实例正在运行。这可以避免多个实例以“None”的 SPJobLockType 运行时发生的冲突,并且还避免了与“ContentDatabase”的 SPJobLockType 关联的令人困惑的(至少我觉得很混乱)操作机制。

这是我编写并发布在 CodePlex 上的计时器作业的链接。它执行与您描述的相同类型的扫描(级别稍高): http://blobcachefarmflush.codeplex.com/SourceControl/changeset/view/53851#797787。计时器作业的实例是在 FeatureReceiver 中使用以下代码行创建的:

BlobCacheFarmFlushTimerJob newJob = new BlobCacheFarmFlushTimerJob(jobName, housingWebApp, null, SPJobLockType.Job);

根据我对您所编写内容的理解,我认为 SPJobLockType 为“Job”是合适的。您希望确保一次仅运行一个作业实例(以防止同一作业的两个或多个实例尝试处理同一个 SPSite)。

我希望这有帮助!

Anoop,

The "sweep" type of timer job you're describing is a fairly common one, and I've written a number of them myself for different projects. In this type of timer job, you're processing a set of sites, webs, or lists to perform some sort of maintenance. It's typically easiest to process one site/web/list at a time, and the task being performed isn't the type that needs to be performed with maximum speed (that is, something that would require a concurrent/multi-threaded processing model to complete quickly).

In this type of scenario, I've generally built my timer jobs to use an SPJobLockType of "Job." As you noted, this ensures that only one instance of the timer job is running at any given time within the farm. This avoids collisions that would occur if multiple instances ran with an SPJobLockType of "None," and it also avoids the confusing (at least I find it confusing) mechanism of operation that is associated with an SPJobLockType of "ContentDatabase."

Here's a link to the timer job I wrote and posted out on CodePlex. It performs the same type of sweep (at a slightly higher-level) that you were describing: http://blobcachefarmflush.codeplex.com/SourceControl/changeset/view/53851#797787. An instance of the timer job is created in a FeatureReceiver with the following line of code:

BlobCacheFarmFlushTimerJob newJob = new BlobCacheFarmFlushTimerJob(jobName, housingWebApp, null, SPJobLockType.Job);

Based on my understanding of what you've written, I believe an SPJobLockType of "Job" would be appropriate. You want to ensure that only one instance of your job is running at a time (to prevent two or more instances of the same job from trying to process the same SPSite).

I hope that helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文