JobListener question

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

JobListener question

Zsolt Kúti-2
Hello,

I want to get notification when a job finished in the following way:

MockJobListener l = new MockJobListener();
scheduler.addJobListener(l);

The problem is that l.jobWasExecuted() is never called (just as any
other methods in it).

Can somebody shed some light how is this supposed to work?

I tried to look at documentation, but examples and docs are missing on
listeners.

Scheduler's API doc claims:
"Client programs may also be interested in the 'listener' interfaces
that are available from Quartz. The JobListener interface provides
notifications of Job executions."

From JobListener's doc:
'"The interface to be implemented by classes that want to be informed
when a JobDetail executes. In general, applications that use a
Scheduler will not have use for this mechanism."

The latter is a bit misleading.


Thanks!
Zsolt

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: JobListener question

James House

See   Scheduler.addGlobalJobListener().


See  http://www.quartz-scheduler.org/docs/tutorial/TutorialLesson07.html


And see code example 9.


james


Kúti Zsolt wrote:

> Hello,
>
> I want to get notification when a job finished in the following way:
>
> MockJobListener l = new MockJobListener();
> scheduler.addJobListener(l);
>
> The problem is that l.jobWasExecuted() is never called (just as any
> other methods in it).
>
> Can somebody shed some light how is this supposed to work?
>
> I tried to look at documentation, but examples and docs are missing on
> listeners.
>
> Scheduler's API doc claims:
> "Client programs may also be interested in the 'listener' interfaces
> that are available from Quartz. The JobListener interface provides
> notifications of Job executions."
>
> From JobListener's doc:
> '"The interface to be implemented by classes that want to be informed
> when a JobDetail executes. In general, applications that use a
> Scheduler will not have use for this mechanism."
>
> The latter is a bit misleading.
>
>
> Thanks!
> Zsolt
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>  


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: JobListener question

Zsolt Kúti-2
Mon, 26 Apr 2010 07:44:01 -0600 -n
James House <[hidden email]> írta:

>
> See   Scheduler.addGlobalJobListener().
>
>
> See
> http://www.quartz-scheduler.org/docs/tutorial/TutorialLesson07.html
>
>
> And see code example 9.

Hello James,

In the meantime I've found global listeners, although still missed the
tutorial section, which explains the relevant bits:

"Global listeners receive events for ALL triggers/jobs, and non-global
listeners receive events only for the specific triggers/jobs that
explicitly name the listener in their getTriggerListenerNames() or
getJobListenerNames() properties"

It would be useful to place this into the API docs.

Thanks for your help!

Zsolt

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: JobListener question

hadjila20
This post has NOT been accepted by the mailing list yet.
In reply to this post by Zsolt Kúti-2
Hi,

I am a beginner in quartz and I would some one to help me please:
I would like to use joblistener order to see the state of my jobs but also to be able to restart on failure.
First I add the xml file of the scheduler follows:

Code:
 <bean id="myJobListener" class="com.hongliang.quartz.MyJobListener">
         <property name="name" value="UnJobListener"/>
     </bean>


Then I create my class joblistener:

Code:
 package com.carte.scheduler;
 
 import org.quartz.JobDetail;
 import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;
 import org.quartz.JobListener;
 import org.springframework.batch.core.JobExecution;
 
 public class UnJobListener implements JobListener {
  public static final String LISTENER_NAME = "dummyJobListenerName";
 
  public UnJobListener() {
  // TODO Auto-generated constructor stub
  }
 
  @Override
  public String getName() {
// TODO Auto-generated method stub
  return LISTENER_NAME;
  }
 
  @Override
  // Run this if job is about to be executed.
  public void jobToBeExecuted(JobExecutionContext context) {
  // TODO Auto-generated method stub
  String jobName = context.getJobDetail().getKey().toString();
  System.out.println("jobToBeExecuted");
  System.out.println("Job : " + jobName + " is going to start...");
  //JobDetail jobDetail = context.getJobDetail();
 //         MyJobDetail myJobDetail = (MyJobDetail) jobDetail;          
 //         jobDetail.getJobDataMap().put("MessageAdded", myJobDetail.getMyMessage());
 
 
 
  }
 
 
  @Override
  public void jobExecutionVetoed(JobExecutionContext context) {
  // TODO Auto-generated method stub
        System.out.println("jobExecutionVetoed");
  }
 
  @Override
  public void jobWasExecuted(JobExecutionContext context,
  JobExecutionException jobException) {
  // TODO Auto-generated method stub
  System.out.println("jobWasExecuted");
 
  String jobName = context.getJobDetail().getKey().toString();
  System.out.println("Job : " + jobName + " is finished...");
 
  if (!jobException.getMessage().equals("")) {
  System.out.println("Exception thrown by: " + jobName
  + " Exception: " + jobException.getMessage());
  }
  }
 
 }
 
 
and there I also developed ablock of code that checks whether the state of the job is failed it i restart but a don't use the joblistener.

now I'm confused I do not know how to do, someone to help me svpp.