-1

QuartzTriggerHandle object that returned by Asynchronous method in Seam always 'null', the job starts but cann't cancelled or paused.

In, seam forum i found the next example that should be work,but it doesn't work with me.

@Name("quartzObserver")
public class SCSQuartzObserver {

    @In(create = true)
    SCSQuartzTask quartzTask;

    @SuppressWarnings("unused")
    @Observer("org.jboss.seam.postInitialization")
    public void observe() {
        try {
            Calendar cal = Calendar.getInstance();
            cal.set(2040, Calendar.MAY, 10);
            QuartzTriggerHandle handle = quartzTask.performTask(new Date(),
                    86400000l);
            handle.cancel();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

@Name("quartzTask")
@AutoCreate
public class SCSQuartzTask {
    @Asynchronous
    public QuartzTriggerHandle performTask(@Expiration java.util.Date when,
            @IntervalDuration long duration) {
        // do stuff
        QuartzTriggerHandle handle = new QuartzTriggerHandle("SCSQuartzTask");
        return handle;
    }
}

thnx for help.

STW
  • 44,917
  • 17
  • 105
  • 161
aatsy
  • 23
  • 8

2 Answers2

0

You shouldn't create the QuartzTriggerHandle. Just do your work in the body of the performTask method, seam runtime will take care to return the QuartzTriggerHandle object. Something like this:

@Asynchronous
public QuartzTriggerHandle performTask(@Expiration java.util.Date when,
        @IntervalDuration long duration) {
    // do stuff
    return null;
}

The QuartzTriggerHandle is serializable, you can keep it in a database table so you can later cancel the task.

dcernahoschi
  • 14,968
  • 5
  • 37
  • 59
0

Hi You must add something in component.xml

1-)async:quartz-dispatcher

2-)xsi:schemaLocation

http://jboss.com/products/seam/async

http://jboss.com/products/seam/async-2.2.xsd"

now it will work

you can find example Melih sakarya web site

http://www.melihsakarya.com/2011/09/seam-de-zamanli-isler-scheduling/

Coding Mash
  • 3,338
  • 5
  • 24
  • 45
erkan
  • 1
  • 1