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.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
-~----------~----~----~----~------~----~------~--~---

Reply via email to