how to create spring quartz like application? - java

Hi i want to create an application that works like spring quartz i can use the spring quartz to do the same my native goal is to create job which may have more then one steps to be executed (trigerred) after that there may be depended jobs also and we shold give the functionality to skip the next execution of particular job.
can any one provide the guidance how the spring quartz actually works?
how to create such application in java using spring ?
thanx in advance.

Thank you everybody for spending your valuable time to reply me I got it work and i found following links very useful.
http://www.mkyong.com/spring/spring-quartz-scheduler-example/
http://static.springsource.org/spring/docs/2.5.x/reference/scheduling.html

That all sounds like stuff you can do with spring/quartz and a queue to queue up your "steps" in.

Related

Spring XD: Is it possible to have multiple jobs in a single module

I'm using Spring XD to execute a batch task, which itself is divided into two separate jobs living in the same (job:)module.
Now I'm quite new to Spring XD/Batch so I only have a rather basic understanding of the framework. I'd like to know if there's a way to address each of those jobs separately? I know I can deploy a job giving it the modules name, however I haven't found a way to specify which job I want to deploy.
Should there be only one job per module? And if not, how can I talk to/deploy each of those jobs separately?
Please let me know if the description of the problem is unclear.
Thanks
Spring XD requires one "main" job to be executed within the module. That being said, Spring XD does support Spring Batch's concept of nested jobs where one job is used to orchestrate the launching of multiple jobs which sounds like it would fit your bill. The "main" job is required to have the id "job". After that, that job can call any number of other jobs packaged in the same module via job steps.

How to monitor Executors or other Task Executing Threads in Spring MVC

I am creating a web application and in this I will be creating many services and executors to do some tasks.I have extended dispacter servlet and started executors or other threads in init method.Is this the right approach?
Now Suppose if any request comes and that executor or similar task executing thread dies after throwing Exception.
1.I suppose that it will affect other requests also.So what shall I do in such cases?
2.How can I create a monitor thread which will check if all critial tasks executing thread and executors are properly running?
3.Should I keep another backup executor prepared and deferred to takeover the failed executor in such situations?If so then how?
It is an old one, but maybe it would help someone :)
For ExecutorService there is a nice example on how to approach the problem in Codahale Metrics: https://github.com/dropwizard/metrics/blob/master/metrics-core/src/main/java/com/codahale/metrics/InstrumentedExecutorService.java
I did not find anything as good for the Spring AsyncTaskExecutors :/
Its been a while since I have used an Executor, are you using one of the built-in executors from Java, Spring, or are you rolling your own? Spring has a bunch, and I think Java gives you two or three concrete implementations.
Anyhow, I think the answer would be to roll some sort of monitoring service, like maybe something using JMX if you have that available. If you wanted to wire your Executors auto-magically you could use the ApplicationContextAware interface to get a reference to the ApplicationContext, which has a method called getBeansOfType(). If you want to take the more straight-forward approach, then you can simply write your monitoring service to inject the executors in there directly.
Another option would be to get an external monitoring framework/app. Something like Dynatrace, which attaches to the JVM process and monitors things or, if you don't mind switching app servers, SpringSource's tcServer, which has optional instrumented Spring JARs and provides a ton of out-of-the-box monitoring.

Scheduled Tasks with Quartz - JDBC

I'm trying to make a mini web application for reminders, I deploy Quartz Scheduler to handle the issue of launch events reminder, I have understood the tasks (Jobs) and programmers (Schedulers) can be configured from a Database with JDBC, I have searched and can not find an example where I show what information should I put on the tables and I run java code to start operating scheduled tasks. If someone can have an example or something that I can serve this purpose, they are grateful.
You have understood wrong. You can use any JobStore (including the JdbcJobStore to store your jobs/triggers/etc. but creating them manually in the database is a bad idea™.
Depending on how you are using Quartz you can set it up, either using SPRING or using the Fluent syntax (which I believe is the preferred method these days).
Further reading: http://quartz-scheduler.org/documentation/quartz-2.1.x/tutorials/tutorial-lesson-09

Activiti Engine Process Definition Listeners

I am building a solution on top of the Activiti Engine (5.9). I need to take some actions right after a new process definition (*.bpmn20.xml) has been deployed or undeployed.
I found a post in the Activiti Forums (post here) with some pointers, like hooks for new a process XML definition being parsed or building some logic around the engine database tables. The post is almost a year old; I am hoping that the situation has changed since then.
So, my question is twofold:
To the people who might have had a similar requirement, how did you approach the problem and what were the pros and cons of your solution?
To the the Activiti project owners, is such a feature considered for the roadmap?
Thanks,
We had a similar problem were we needed to "hack" into the engine. We hoped Activiti will create a central bus or notifications but it seems it will take some time for what we understood. I have wrote a blog post here, where you can see what we did. Hope it will help...

How to run multiple jobs with spring quartz and the jobs are feched from database

How to run multiple jobs with spring quartz and the jobs are feched from database.
Please provide any example code.
There are several parts to this question:
How to run Quartz.
How to connect to a database.
How to create a schema to describe "jobs".
How to create and execute a "job" from the schema.
Marry all these together and you'll answer your own question.
Computer science is about decomposition: breaking large problems into smaller ones that you can handle. I'd recommend taking that approach here.
Well you can start by reading the documentation here and here. If you then have a more specific question, then come back and ask it.

Categories