[Logo] Terracotta Discussion Forums (LEGACY READ-ONLY ARCHIVE)
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
[Expert]
Messages posted by: Anonymous  XML
Profile for Anonymous -> Messages posted by Anonymous [25] Go to Page: 1, 2 Next 
Author Message
Hello,

maybe someone can help.

Following situation:

I want to use quartz in an web application. So I init quartz with the org.quartz.ee.servlet.QuartzInitializerServlet. After this my servlet is started, which creates a job and schedule it with a crontrigger. The job should start every minute. This works fine. So my Job creates some jobs every time, which starts directly.

My problem is now, that I want to reconfigure the first job to run on different times (maybe every minute, maybe every two minutes, then every minute again). I try to reschedule the job with a changed trigger. At the moment I use a Listener for the trigger to reschedule after complete of the trigger. This seems not to work, because the listener is called after the reschedule, so this can result in a not wanted loop.

Is there a working solution for doing my task?

Best regards

Thorsten
Hello,

I'm a new user of Quartz and want to set it up with a database. I've encounted a small problem that I hope you can help with.

When I have created jobs and triggers in the database that I have associated Quartz with and I shutdown the Quartz server, is there anyway that it can auto import the jobs and triggers already stored in the database into the scheduler?

/Jeppe
It's something we are looking doing for sure.
"graphical or GUI" should have been "command-line, GUI or web-based"
Are there any admin tools for Quartz (list, pause, delete jobs and so on), either graphical or GUI?
Excellent.

Would be good to mention this scenario in the official documentation, as I think it is quite common.

Also, for using a non-started Scheduler to inject jobs into the database, maybe there should be a new Scheduler implementation for that, one that cannot be accidentally started (and one that does not create a thread pool that is never used) and that does not need to be shutdown. Maybe it is worth to break up the Scheduler interface into the Scheduler part and the Executor part.
Thanks for your reply

I have a valid sql query as follows in quartz.properties

org.quartz.datasource.myDS.validationQuery = select 1
We are running with strange issue. We use quartz to load the list job. But, when you leave the system ruuning overnight, the very first job everyday is failed because the following exception. Subsequent jobs are executed with no problem. We use DBCP connection pool and MSSQL DB.

Looks like Quartz tries to use the connection which is used by someone outside the quartz, from connection pool and failed to override its default settings

Any thoughts.

2009-11-06 02:29:27,810 WARN [com.arjuna.ats.jta.logging.loggerI18N] [com.arjuna.ats.internal.jta.transaction.arjunacore.lastResource.multipleWarning] [com.arjuna.ats.internal.jta.transaction.arjunacore.lastResource.multipleWarning] Multiple last resources have been added to the current transaction. This is transactionally unsafe and should not be relied upon. Current resource is org.jboss.resource.connectionmanager.TxConnectionManager$LocalXAResource@40ff16d1
2009-11-06 02:29:27,813 WARN [org.quartz.impl.jdbcjobstore.JobStoreTX] Failed to override connection auto commit/transaction isolation.
java.sql.SQLException: I/O Error: Connection reset
at net.sourceforge.jtds.jdbc.TdsCore.executeSQL(TdsCore.java:1049)
at net.sourceforge.jtds.jdbc.TdsCore.submitSQL(TdsCore.java:895)
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.setAutoCommit(ConnectionJDBC2.java:2026)
at org.apache.commons.dbcp.DelegatingConnection.setAutoCommit(DelegatingConnection.java:331)
at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.setAutoCommit(PoolingDataSource.java:317)
at org.quartz.impl.jdbcjobstore.AttributeRestoringConnectionInvocationHandler.setAutoCommit(AttributeRestoringConnectionInvocationHandler.java:91)
at org.quartz.impl.jdbcjobstore.AttributeRestoringConnectionInvocationHandler.invoke(AttributeRestoringConnectionInvocationHandler.java:65)
at $Proxy196.setAutoCommit(Unknown Source)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.getConnection(JobStoreSupport.java:658)
at org.quartz.impl.jdbcjobstore.JobStoreTX.getNonManagedTXConnection(JobStoreTX.java:72)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3671)
at org.quartz.impl.jdbcjobstore.JobStoreTX.executeInLock(JobStoreTX.java:93)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeWithoutLock(JobStoreSupport.java:3579)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.retrieveJob(JobStoreSupport.java:1317)
at org.quartz.core.QuartzScheduler.getJobDetail(QuartzScheduler.java:1295)
at org.quartz.impl.StdScheduler.getJobDetail(StdScheduler.java:551)
at com.dconx.swx.ejb.helpers.ListloadUtil.scheduleDefaultJobForClient(ListloadUtil.java:1427)
I fixed it like so ....


Code:
public class ExampleJob implements Job, InterruptableJob {
 
 
 	@Override
 	public void execute(JobExecutionContext jobContext) throws JobExecutionException {
 		JobDataMap dataMap = jobContext.getMergedJobDataMap();
 		System.out.println("starting job");
 		try {
 			System.out.println("mykey: " + dataMap.get("mykey"));
 			Thread.sleep(30000); // pretend like we are doing something
 		} catch (InterruptedException ie) {
 			System.out.println("job interrupted by a timeout");
 		}
 		System.out.println("ending job");
 	}
 
 	@Override
 	public void interrupt() throws UnableToInterruptJobException {
 		System.out.println("job interrupted");
 	}
 }
Does anyone knows if there is a new version of Quartz web app is available or where can I download the latest quartz web app?
I need to set some data on my job instances for each trigger. I also need a timeout mechanism, which seems to be working for me so far. However, my property does not seem to be getting set from the JobDataMap when my job runs.

What am I doing wrong?


Code:
Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
 scheduler.start();
 JobListener listener1 = new ExampleJobListener("job1Listener");
 JobListener listener2 = new ExampleJobListener("job2Listener");
 JobDetail job1 = new JobDetail("job1", "group1", ExampleJob.class);
 JobDetail job2 = new JobDetail("job2", "group1", ExampleJob.class);
 job1.addJobListener("job1Listener");
 job2.addJobListener("job2Listener");
 JobDataMap jobData1 = new JobDataMap();
 jobData1.put("mykey", "Hello Job1");
 JobDataMap jobData2 = new JobDataMap();
 jobData2.put("mykey", "Hello Job2");
 Trigger trigger1 = new CronTrigger("trigger1", "group1", "10 * * * * ?");
 Trigger trigger2 = new CronTrigger("trigger2", "group1", "10 * * * * ?");
 trigger1.setJobDataMap(jobData1);
 trigger2.setJobDataMap(jobData2);
 scheduler.addJobListener(listener1);
 scheduler.addJobListener(listener2);
 scheduler.scheduleJob(job1, trigger1);
 scheduler.scheduleJob(job2, trigger2);



Code:
public class ExampleJob implements Job, InterruptableJob {
 	private String mykey;
 
 	public void setMykey(String mykey) {
 		this.mykey = mykey;
 	}
 
 	@Override
 	public void execute(JobExecutionContext jobContext) throws JobExecutionException {
 		System.out.println("starting job");
 		try {
 			System.out.println("mykey: " + this.mykey);
 			Thread.sleep(30000); // pretend like we are doing something
 		} catch (InterruptedException ie) {
 			System.out.println("job interrupted by a timeout");
 		}
 		System.out.println("ending job");
 	}
 
 	@Override
 	public void interrupt() throws UnableToInterruptJobException {
 		System.out.println("job interrupted");
 	}
 }


Code:
public class ExampleJobListener implements JobListener {
 
 	private Thread timeoutThread;
 	private final String name;
 
 	public ExampleJobListener(String name) {
 		this.name = name;
 	}
 
 	@Override
 	public String getName() {
 		return this.name;
 	}
 
 	@Override
 	public void jobExecutionVetoed(JobExecutionContext jobContext) {}
 
 	@Override
 	public void jobToBeExecuted(JobExecutionContext jobContext) {
 		this.timeoutThread = new JobTimeoutThread(jobContext);
 		this.timeoutThread.run();
 	}
 
 	@Override
 	public void jobWasExecuted(JobExecutionContext jobContext, JobExecutionException jee) {
 		this.timeoutThread.interrupt();
 	}
 
 }


Code:
public class JobTimeoutThread extends Thread {
 
 	private final JobExecutionContext jobContext;
 
 	public JobTimeoutThread(JobExecutionContext jobContext) {
 		this.jobContext = jobContext;
 	}
 
 	@Override
 	public void run() {
 		try {
 			System.out.println("starting job timeout thread");
 			sleep(5000);
 			System.out.println("thread timed out, interrupting job ...");
 			((InterruptableJob) this.jobContext.getJobInstance()).interrupt();
 		} catch (InterruptedException e) {
 			System.out.println("timeout thread interrupted");
 		} catch (UnableToInterruptJobException e) {
 			System.out.println("timeout thread failed to interrupt job");
 		}
 	}
 
 }
Hi all,

I am working on an application, where we require a job schedular.
Requirement is , that the job schedular works alone, fetchs jobs from a database and execute them.
Is this possible with Quartz?

Any pointers in this direction will be helpful.

Thanks.
Follow-up question:

How about a cluster where I put all instances except one into standby mode at all time?

Would clock drift still be an issue in this situation?
Crosspost from StackOverflow:

http://stackoverflow.com/questions/1777478/can-i-inject-new-jobs-into-the-quartz-jdbcjobstore-without-clustering-enabled

I cannot guarantee complete clock synchronization, so instead of using the clustering feature I was thinking to have a single Quartz instance (with a stand-by for fail-over). Having a single instance executing jobs is not a problem, but I still need all of the web servers to be able to schedule jobs.

Can I directly add jobs into the JDBCJobStore from the web servers, and will they be picked up by the (non-clustered) Quartz server? I would be doing this by creating schedule instances in the web servers to add jobs. These instances would never be started, just used to access the JobStore.

Initial experimentation indicates that it seems to work: I wrote a test program that creates a "non-clustered" Quartz scheduler using the same JobStore as the "real" scheduler (also non-clustered), and schedules jobs. After a few seconds, these jobs do get executed.

Does this really work reliably?
> Never run clustering on separate machines, unless their clocks are synchronized using some form of time-sync service (daemon) that runs very regularly (the clocks must be within a second of each other).

That is a scary warning.

What exactly can happen when the clocks are not completely synched?

And does this really only affect a cluster? How about an RMI server with clients that schedule jobs with time stamps that are off?

 
Profile for Anonymous -> Messages posted by Anonymous [25] Go to Page: 1, 2 Next 
Go to:   
Powered by JForum 2.1.7 © JForum Team