Questions regarding Quartz.net - quartz.net

Please help me clear the following doubts.
1) I am using the GetScheduler() method to assign the scheduler to a local variable. Does the scheduler automatically starts when GetScheduler() called? If yes,how does the scheduler starts if there is a persistent job available. Who is calling GetScheduler then?
2) Is storing the scheduler in a local variable(inside a function) safe?
2) How can i configure the quartz.net properties such as thread pool size,database configuration,etc.
Awaiting your valuable reply.
Thanks in advance,
John.

What language are you using to work with the Quartz scheduler, you have tagged this post with both the Java and .Net versions.
The basic approach is to construct the scheduler factory and obtain a scheduler instance from that object. After this create a trigger and define the Job.
Basically the trigger says when to run the job and the job object is the code which performs an action.
I highly recommend reading through the tutorial code on the relevant Quartz website, it answers your above questions. If that doesnt help then post back with some sample code.

Related

Does spring-cloud-dataflow provide support for scheduling applications defined as tasks?

I have been looking at using projects built using spring-cloud-task within spring-cloud-dataflow. Having looked at the example projects and the documentation, the indication seems to be that tasks are launched manually through the dashboard or the shell. Does spring-cloud-dataflow provide any way of scheduling task definitions so that they can run for example on a cron schedule? I.e. Can you create a spring-cloud-task app which itself has no knowledge of a schedule, but deploy it to the dataflow server and configure the scheduling there?
Among the posts and blogs I have looked at I noticed the following:
https://spring.io/blog/2016/01/27/introducing-spring-cloud-task
Some of the Q&A afterwards hints at this being a possibility, with the reference to triggers, but I think this was discussed before it was released.
Any advice would be greatly appreciated, many thanks.
There are few ways you could launch Tasks in Spring Cloud Data Flow. Following are the available options today.
Launch it using TriggerTask; with this you could either choose to launch it with fixedDelay or via a cron expression - example here.
Launch it via an event in streaming pipeline. Imagine a use-case where you would want to create a "thumbnail" as and when there's a new image (event) in s3-bucket or in a file-system directory; the "thumbnail" operation could be a task in this case - example here.
Lastly, in the upcoming releases, we will port over "scheduler" functionality from Spring XD to Spring Cloud Data Flow.
Yes, Spring Cloud Data Flow does provide a scheduling option. To enable it, you need to add below arguments while starting the server:
--spring.cloud.dataflow.features.schedules-enabled=true

rails scheduler daemon run task immediately

I am using https://github.com/ssoroka/scheduler_daemon for my scheduled jobs, but I would like jobs immediately with a command (rather than waiting for the delay specified in the task).
I've tried using rails runner TaskName.run but the class can never be found (runner.rb:53:in 'eval': uninitialized constant TaskName (NameError)).
How can I run the scheduled tasks immediately?
If I guess correctly, you want to call one of the scheduled task directly.
If I were you, I'd ask to the author directly, via the channel he points at in the readme: https://github.com/ssoroka/scheduler_daemon/issues
If there is a way to do it, I'm sure the author will be glad to explain it in the readme as well.
Corollary question: for a one-time schedule, do you want your direct trigger to cancel the schedule?
You don't need the scheduler to run the task for you, just call the MyTask.new.run directly.

Rails 3 Timer to run a method (Delayed Job)

I want to set a timer on server side to run a method at a specific time. Has anybody done this using just rails and no AJAX? Thanks a lot. I'd appreciate any input :)
update:
I've read about Delayed Job written by the amazing guys at Shopify. I think this might just do the trick
Your question is a little too vague to answer concisely. You may be looking for one of the following things:
A client-side redirect on a timer with http-equiv headers.
A cron task that executes rails runner on a regular schedule.
A timeout on an operation being performed, such as using Timeout.

The best way to implement a background service in Grails

I have done a lot of searching and I am aware of grails-executor and the JMS plugin. I am looking for advice on the best way to implement a long running (as long as the application is running) service that runs in the background and accepts input on a blocking queue. It seems that there at two ways to satisfy my requirements... 1. JMS (which feels overly heavy handed) and 2. a service running on a thread that watches the queue... when something is added to it, it processes it and then waits for the next item. This service needs to have GORM capability so that it can create/save objects. My preference is to startup some type of service on a thread and use a blocking queue... Can anyone suggest the best way to do this? Should I just implement a class that gets called when grails bootstraps and have that class use the grails-executor to create a thread that just runs in the background? If anyone has used the jms plugin in grails, is it sufficiently lightweight that I should reconsider my position on this? Any and all advice is greatly appreciated. I am really NOT tied to any one solution, so all ideas will be considered and very much appreciated.
Thanks in advance!
I use the quartz plugin for a lot of similar "queue watching" functionality.
You can use Spring integration instead. With quartz you have to develop you enqueuing logic but with spring integration every thing is pre-developed.

How to implement background processing for ASP.Net MVC website in a shared hosting environment?

I am developing my first web application using ASP.Net MVC, and I am in a situation where I would like a background service to process status notifications outside of the application, not unlike the reputation/badge system on stackoverflow.
What is the best way to handle something like this? Is it even possible in a shared-hosting environment like Godaddy, which I am using.
I don't need to communicate with the background worker directly, since I will be adding notification records to a database table with a column set to an "unprocessed" state. Then the worker will just scan the table on a regular schedule and processes what is ready.
Thanks for your advice.
Have you tried with quartz.net? I think it may fit your needs.
also take a look at this Simulate a Windows Service using ASP.NET to run scheduled jobs article.
it explains a nice way to schedule operations with no outer dependence.
The idea is to use Cache timeout to control the schedule. I've implemented it successfully on a project which required regular temp file cleaning. This cleaning is a bit heavy so we move this clean operation in a scheduled job (using the asp.net cache) to avoid having to deploy scheduled task or custom program.
To answer whether GoDaddy will support a seperate service you need to ask them.
However there are a number of creative ways that you can "get around" this issue on shared hosting.
Have a secure page that's purpose is to execute your background work. You could have scheduled task on a machine under your control that calls to this web page at set intervals.
Use a variation of the Background Worker Thread answer from #safi. Your background worker thread could check to see if another is already processing and stop, so that only one instance is running at a time.
If only one background task is enough for you then use the WebBackgrounder
And this is the article with detailed explanation.

Resources