nope, here is what my config looks like:
<component
id="scheduler.starter"
type="DFAT.SWAT.WCF.Services.SchedulerStarter, DFAT.SWAT.WCF"
service="Castle.Core.IStartable, Castle.Core" />
And the implementation of SchedulerStarter: (Note: I've created a IJobSpec
interface to register jobs)
public class SchedulerStarter : IStartable
{
private readonly IScheduler scheduler;
private readonly IKernel kernel;
private ILogger logger;
public SchedulerStarter(IScheduler scheduler, IKernel kernel)
{
logger = NullLogger.Instance;
this.scheduler = scheduler;
this.kernel = kernel;
}
public ILogger Logger
{
get { return logger; }
set { logger = value; }
}
#region Implementation of IStartable
/// <summary>
/// Starts this instance.
/// </summary>
public void Start()
{
var jobSpecs = kernel.ResolveAll<IJobSpec>();
logger.InfoFormat("{0} jobs found.", jobSpecs.Length);
foreach (var spec in jobSpecs)
{
var jobSpec = new JobSpec(spec.Name, spec.Description,
spec.JobId, spec.Trigger);
scheduler.CreateJob(jobSpec, CreateJobConflictAction.Replace);
logger.InfoFormat("{0} job found.", spec.Name);
}
if (jobSpecs.Length > 0)
{
logger.Debug("Starting Scheduler");
scheduler.Start();
}
}
/// <summary>
/// Stops this instance.
/// </summary>
public void Stop()
{
if (scheduler.IsRunning)
{
scheduler.Stop();
}
scheduler.Dispose();
}
#endregion
}
I hope this helps :)
John
________________________________
From: jsmorris <[email protected]>
To: [email protected]
Sent: Thursday, 28 May, 2009 12:04:32 PM
Subject: Re: Using Component.Scheduler in Monorail produces random job failures
@John
I am assuming you configured it something like this (since I didn't
see that the DefaultScheduler implemented IStartable)
<components>
<component id="Core.Scheduling.Scheduler"
service="Castle.Components.Scheduler.IScheduler,
Castle.Components.Scheduler"
type="Castle.Components.Scheduler.DefaultScheduler,
Castle.Components.Scheduler"
startable="true" startMethod="Start" stopMethod="Stop" />
</components>
After I tried this, I still got the errors...bummer.
Jason
On Wed, May 27, 2009 at 10:23 PM, John Simons
<[email protected]> wrote:
> Hi Jason,
>
> I use the Scheduler with Monorail and I'm not experiencing any problems.
>
> The difference is that I start my Scheduler using the Startable Facility
> (http://www.castleproject.org/container/facilities/trunk/startable/index.html),
> have a look at the doco.
>
> Not sure why it would be failing randomly! I'll try to replicate your setup
> today and report on the results later on.
>
> Cheers
> John
>
>
>
> ________________________________
> From: jsmorris <[email protected]>
> To: [email protected]
> Sent: Thursday, 28 May, 2009 6:05:51 AM
> Subject: Using Component.Scheduler in Monorail produces random job failures
>
>
> I am exploring the use of Component.Scheduler to execute a few, short
> duration jobs within my monorail web app. I have read people's
> concern about asp.net killing your threads before the job is complete.
> Let's ignore that for the time being, unless using the
> Component.Scheduler in a monorail web app is impossible.
>
> I am running locally on the ASP.NET Development Server (not IIS)
> running castle nightly build 1126.
>
> I have written my Global.cs as such to start and stop the scheduler,
> plus adding a very basic job.
>
> public class Global : HttpApplication, IContainerAccessor
> {
> private static IWindsorContainer _container;
>
> public IWindsorContainer Container { get { return _container; } }
>
> protected void Application_Start(Object sender, EventArgs e)
> {
> _container = new IoCContainer("Web.config");
>
> var jobSpec = new JobSpec("NoOp job.", "A test job.",
> "NoOpJob", new PeriodicTrigger(new DateTime(1900, 1, 1), new
> DateTime(2900, 1, 1), new TimeSpan(0, 0, 10), 1000));
>
> _container.Resolve<IScheduler>().CreateJob(jobSpec,
> CreateJobConflictAction.Ignore);
> _container.Resolve<IScheduler>().Start();
> }
>
> protected void Application_End(Object sender, EventArgs e)
> {
> _container.Resolve<IScheduler>().Stop();
> _container.Dispose();
> }
> }
>
> My job is
>
> public class NoOpJob : IJob
> {
> public Boolean Execute(JobExecutionContext context)
> {
> context.Logger.DebugFormat("Hello World - {0}",
> DateTime.Now.ToShortTimeString());
> return true;
> }
> }
>
> After starting my web app, I am seeing jobs fail sporadically. I am
> not seeing any pattern. A sample of my log is
>
> 2009-05-27 12:45:10,006 [Job Watcher for
> 'JMORRIS2-MOBL1/WebDev.WebServer, Scheduler #1'.] [INFO
> ]Castle.Components.Scheduler.DefaultScheduler.BeginExecuteJob - Job
> 'NoOp job.' started at 5/27/2009 7:45:10 PM.
> 2009-05-27 12:45:10,006 [4] [INFO
> ]Castle.Components.Scheduler.DefaultScheduler.EndExecuteJob - Job
> 'NoOp job.' completed successfully at 5/27/2009 7:45:10 PM.
> 2009-05-27 12:45:20,007 [Job Watcher for
> 'JMORRIS2-MOBL1/WebDev.WebServer, Scheduler #1'.] [INFO
> ]Castle.Components.Scheduler.DefaultScheduler.BeginExecuteJob - Job
> 'NoOp job.' started at 5/27/2009 7:45:20 PM.
> 2009-05-27 12:45:20,007 [4]
> [ERROR]Castle.Components.Scheduler.DefaultScheduler.EndExecuteJob -
> Job 'NoOp job.' completed with an error at 5/27/2009 7:45:20 PM.
> 2009-05-27 12:45:30,007 [Job Watcher for
> 'JMORRIS2-MOBL1/WebDev.WebServer, Scheduler #1'.] [INFO
> ]Castle.Components.Scheduler.DefaultScheduler.BeginExecuteJob - Job
> 'NoOp job.' started at 5/27/2009 7:45:30 PM.
> 2009-05-27 12:45:30,007 [4] [INFO
> ]Castle.Components.Scheduler.DefaultScheduler.EndExecuteJob - Job
> 'NoOp job.' completed successfully at 5/27/2009 7:45:30 PM.
> 2009-05-27 12:45:40,008 [Job Watcher for
> 'JMORRIS2-MOBL1/WebDev.WebServer, Scheduler #1'.] [INFO
> ]Castle.Components.Scheduler.DefaultScheduler.BeginExecuteJob - Job
> 'NoOp job.' started at 5/27/2009 7:45:40 PM.
> 2009-05-27 12:45:40,008 [9] [INFO
> ]Castle.Components.Scheduler.DefaultScheduler.EndExecuteJob - Job
> 'NoOp job.' completed successfully at 5/27/2009 7:45:40 PM.
> 2009-05-27 12:45:50,008 [Job Watcher for
> 'JMORRIS2-MOBL1/WebDev.WebServer, Scheduler #1'.] [INFO
> ]Castle.Components.Scheduler.DefaultScheduler.BeginExecuteJob - Job
> 'NoOp job.' started at 5/27/2009 7:45:50 PM.
> 2009-05-27 12:45:50,008 [9] [INFO
> ]Castle.Components.Scheduler.DefaultScheduler.EndExecuteJob - Job
> 'NoOp job.' completed successfully at 5/27/2009 7:45:50 PM.
> 2009-05-27 12:46:00,009 [Job Watcher for
> 'JMORRIS2-MOBL1/WebDev.WebServer, Scheduler #1'.] [INFO
> ]Castle.Components.Scheduler.DefaultScheduler.BeginExecuteJob - Job
> 'NoOp job.' started at 5/27/2009 7:46:00 PM.
> 2009-05-27 12:46:00,009 [4]
> [ERROR]Castle.Components.Scheduler.DefaultScheduler.EndExecuteJob -
> Job 'NoOp job.' completed with an error at 5/27/2009 7:46:00 PM.
> 2009-05-27 12:46:10,009 [Job Watcher for
> 'JMORRIS2-MOBL1/WebDev.WebServer, Scheduler #1'.] [INFO
> ]Castle.Components.Scheduler.DefaultScheduler.BeginExecuteJob - Job
> 'NoOp job.' started at 5/27/2009 7:46:10 PM.
> 2009-05-27 12:46:10,009 [9] [INFO
> ]Castle.Components.Scheduler.DefaultScheduler.EndExecuteJob - Job
> 'NoOp job.' completed successfully at 5/27/2009 7:46:10 PM.
> 2009-05-27 12:46:20,010 [Job Watcher for
> 'JMORRIS2-MOBL1/WebDev.WebServer, Scheduler #1'.] [INFO
> ]Castle.Components.Scheduler.DefaultScheduler.BeginExecuteJob - Job
> 'NoOp job.' started at 5/27/2009 7:46:20 PM.
> 2009-05-27 12:46:20,010 [4] [INFO
> ]Castle.Components.Scheduler.DefaultScheduler.EndExecuteJob - Job
> 'NoOp job.' completed successfully at 5/27/2009 7:46:20 PM.
>
> Before continuing on with this experiment (or debugging into the
> castle code), I had a few questions that maybe others have already
> answered.
>
> 1) Why is the (rather simple) job sporadically failing? Is there a
> way to see why the job is failing?
>
> 2) Can I catch the exception and expose it to my code so I can do
> something with it?
>
> 2) Is there a better way to configure the scheduler to start in a web app?
>
> Thanks,
> Jason
>
> ________________________________
> Need a Holiday? Win a $10,000 Holiday of your choice. Enter now..
> >
>
Need a Holiday? Win a $10,000 Holiday of your choice. Enter
now.http://us.lrd.yahoo.com/_ylc=X3oDMTJxN2x2ZmNpBF9zAzIwMjM2MTY2MTMEdG1fZG1lY2gDVGV4dCBMaW5rBHRtX2xuawNVMTEwMzk3NwR0bV9uZXQDWWFob28hBHRtX3BvcwN0YWdsaW5lBHRtX3BwdHkDYXVueg--/SIG=14600t3ni/**http%3A//au.rd.yahoo.com/mail/tagline/creativeholidays/*http%3A//au.docs.yahoo.com/homepageset/%3Fp1=other%26p2=au%26p3=mailtagline
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---