org.quartz.impl.triggers.SimpleTriggerImpl#setJobDataMap ( )源码实例Demo

下面列出了org.quartz.impl.triggers.SimpleTriggerImpl#setJobDataMap ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

protected void scheduleMessage(PersistedMessageBO message) throws SchedulerException {
 LOG.debug("Scheduling execution of a delayed asynchronous message.");
 Scheduler scheduler = KSBServiceLocator.getScheduler();
 JobDataMap jobData = new JobDataMap();
 jobData.put(MessageServiceExecutorJob.MESSAGE_KEY, message);

    JobDetailImpl jobDetail = new JobDetailImpl("Delayed_Asynchronous_Call-" + Math.random(), "Delayed_Asynchronous_Call",
  MessageServiceExecutorJob.class);
 jobDetail.setJobDataMap(jobData);

    scheduler.getListenerManager().addJobListener( new MessageServiceExecutorJobListener());

    SimpleTriggerImpl trigger = new SimpleTriggerImpl("Delayed_Asynchronous_Call_Trigger-" + Math.random(),
  "Delayed_Asynchronous_Call", message.getQueueDate());

    trigger.setJobDataMap(jobData);// 1.6 bug required or derby will choke
 scheduler.scheduleJob(jobDetail, trigger);
}
 
源代码2 项目: rice   文件: DefaultExceptionServiceImpl.java
public void scheduleExecution(Throwable throwable, PersistedMessageBO message, String description) throws Exception {
	KSBServiceLocator.getMessageQueueService().delete(message);
       PersistedMessageBO messageCopy = message.copy();
	Scheduler scheduler = KSBServiceLocator.getScheduler();
	JobDataMap jobData = new JobDataMap();
	jobData.put(MessageServiceExecutorJob.MESSAGE_KEY, messageCopy);
	JobDetailImpl jobDetail = new JobDetailImpl("Exception_Message_Job " + Math.random(), "Exception Messaging",
		MessageServiceExecutorJob.class);
	jobDetail.setJobDataMap(jobData);

       if (!StringUtils.isBlank(description)) {
	    jobDetail.setDescription(description);
	}

       scheduler.getListenerManager().addJobListener( new MessageServiceExecutorJobListener());

       SimpleTriggerImpl trigger = new SimpleTriggerImpl("Exception_Message_Trigger " + Math.random(), "Exception Messaging", messageCopy
		.getQueueDate());
	trigger.setJobDataMap(jobData);// 1.6 bug required or derby will choke

       scheduler.scheduleJob(jobDetail, trigger);
}
 
@Override
public void afterPropertiesSet() {
	if (this.name == null) {
		this.name = this.beanName;
	}
	if (this.group == null) {
		this.group = Scheduler.DEFAULT_GROUP;
	}
	if (this.jobDetail != null) {
		this.jobDataMap.put("jobDetail", this.jobDetail);
	}
	if (this.startDelay > 0 || this.startTime == null) {
		this.startTime = new Date(System.currentTimeMillis() + this.startDelay);
	}

	SimpleTriggerImpl sti = new SimpleTriggerImpl();
	sti.setName(this.name != null ? this.name : toString());
	sti.setGroup(this.group);
	if (this.jobDetail != null) {
		sti.setJobKey(this.jobDetail.getKey());
	}
	sti.setJobDataMap(this.jobDataMap);
	sti.setStartTime(this.startTime);
	sti.setRepeatInterval(this.repeatInterval);
	sti.setRepeatCount(this.repeatCount);
	sti.setPriority(this.priority);
	sti.setMisfireInstruction(this.misfireInstruction);
	sti.setDescription(this.description);
	this.simpleTrigger = sti;
}
 
@Override
public void afterPropertiesSet() {
	if (this.name == null) {
		this.name = this.beanName;
	}
	if (this.group == null) {
		this.group = Scheduler.DEFAULT_GROUP;
	}
	if (this.jobDetail != null) {
		this.jobDataMap.put("jobDetail", this.jobDetail);
	}
	if (this.startDelay > 0 || this.startTime == null) {
		this.startTime = new Date(System.currentTimeMillis() + this.startDelay);
	}

	SimpleTriggerImpl sti = new SimpleTriggerImpl();
	sti.setName(this.name != null ? this.name : toString());
	sti.setGroup(this.group);
	if (this.jobDetail != null) {
		sti.setJobKey(this.jobDetail.getKey());
	}
	sti.setJobDataMap(this.jobDataMap);
	sti.setStartTime(this.startTime);
	sti.setRepeatInterval(this.repeatInterval);
	sti.setRepeatCount(this.repeatCount);
	sti.setPriority(this.priority);
	sti.setMisfireInstruction(this.misfireInstruction);
	sti.setDescription(this.description);
	this.simpleTrigger = sti;
}
 
源代码5 项目: lams   文件: SimpleTriggerFactoryBean.java
@Override
public void afterPropertiesSet() {
	if (this.name == null) {
		this.name = this.beanName;
	}
	if (this.group == null) {
		this.group = Scheduler.DEFAULT_GROUP;
	}
	if (this.jobDetail != null) {
		this.jobDataMap.put("jobDetail", this.jobDetail);
	}
	if (this.startDelay > 0 || this.startTime == null) {
		this.startTime = new Date(System.currentTimeMillis() + this.startDelay);
	}

	SimpleTriggerImpl sti = new SimpleTriggerImpl();
	sti.setName(this.name);
	sti.setGroup(this.group);
	if (this.jobDetail != null) {
		sti.setJobKey(this.jobDetail.getKey());
	}
	sti.setJobDataMap(this.jobDataMap);
	sti.setStartTime(this.startTime);
	sti.setRepeatInterval(this.repeatInterval);
	sti.setRepeatCount(this.repeatCount);
	sti.setPriority(this.priority);
	sti.setMisfireInstruction(this.misfireInstruction);
	sti.setDescription(this.description);
	this.simpleTrigger = sti;
}
 
@Override
public void afterPropertiesSet() {
	if (this.name == null) {
		this.name = this.beanName;
	}
	if (this.group == null) {
		this.group = Scheduler.DEFAULT_GROUP;
	}
	if (this.jobDetail != null) {
		this.jobDataMap.put("jobDetail", this.jobDetail);
	}
	if (this.startDelay > 0 || this.startTime == null) {
		this.startTime = new Date(System.currentTimeMillis() + this.startDelay);
	}

	SimpleTriggerImpl sti = new SimpleTriggerImpl();
	sti.setName(this.name);
	sti.setGroup(this.group);
	sti.setJobKey(this.jobDetail.getKey());
	sti.setJobDataMap(this.jobDataMap);
	sti.setStartTime(this.startTime);
	sti.setRepeatInterval(this.repeatInterval);
	sti.setRepeatCount(this.repeatCount);
	sti.setPriority(this.priority);
	sti.setMisfireInstruction(this.misfireInstruction);
	sti.setDescription(this.description);
	this.simpleTrigger = sti;
}
 
源代码7 项目: rice   文件: MessagingServiceImpl.java
private void scheduleJob() {
    LOG.debug("Queueing processing job");
    try {
        Scheduler scheduler = KSBServiceLocator.getScheduler();
        if (synchronous) {
            LOG.debug("Invoking job synchronously in Thread " + Thread.currentThread());
            MessageProcessingJob job = new MessageProcessingJob(messageId, mode, user, cause);
            job.run();
        } else {
            String uniqueTriggerName = jobName + "-Trigger-" + System.currentTimeMillis() + Math.random();
            SimpleTriggerImpl trigger = new SimpleTriggerImpl(uniqueTriggerName, jobGroup + "-Trigger");
            LOG.debug("Scheduling trigger: " + trigger);

            JobDataMap data = new JobDataMap();
            data.put("mode", mode.name());
            data.put("user", user);
            data.put("cause", cause);
            data.put("messageId", messageId);

            trigger.setJobName(jobName);
            trigger.setJobGroup(jobGroup);
            trigger.setJobDataMap(data);
            scheduler.scheduleJob(trigger);
        }
    } catch (SchedulerException se) {
        throw new RuntimeException(se);
    }
}
 
源代码8 项目: lams   文件: StdJDBCDelegate.java
/**
 * <p>
 * Select all of the triggers for jobs that are requesting recovery. The
 * returned trigger objects will have unique "recoverXXX" trigger names and
 * will be in the <code>{@link
 * org.quartz.Scheduler}.DEFAULT_RECOVERY_GROUP</code>
 * trigger group.
 * </p>
 * 
 * <p>
 * In order to preserve the ordering of the triggers, the fire time will be
 * set from the <code>COL_FIRED_TIME</code> column in the <code>TABLE_FIRED_TRIGGERS</code>
 * table. The caller is responsible for calling <code>computeFirstFireTime</code>
 * on each returned trigger. It is also up to the caller to insert the
 * returned triggers to ensure that they are fired.
 * </p>
 * 
 * @param conn
 *          the DB Connection
 * @return an array of <code>{@link org.quartz.Trigger}</code> objects
 */
public List<OperableTrigger> selectTriggersForRecoveringJobs(Connection conn)
    throws SQLException, IOException, ClassNotFoundException {
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
        ps = conn
                .prepareStatement(rtp(SELECT_INSTANCES_RECOVERABLE_FIRED_TRIGGERS));
        ps.setString(1, instanceId);
        setBoolean(ps, 2, true);
        rs = ps.executeQuery();

        long dumId = System.currentTimeMillis();
        LinkedList<OperableTrigger> list = new LinkedList<OperableTrigger>();
        while (rs.next()) {
            String jobName = rs.getString(COL_JOB_NAME);
            String jobGroup = rs.getString(COL_JOB_GROUP);
            String trigName = rs.getString(COL_TRIGGER_NAME);
            String trigGroup = rs.getString(COL_TRIGGER_GROUP);
            long firedTime = rs.getLong(COL_FIRED_TIME);
            long scheduledTime = rs.getLong(COL_SCHED_TIME);
            int priority = rs.getInt(COL_PRIORITY);
            @SuppressWarnings("deprecation")
            SimpleTriggerImpl rcvryTrig = new SimpleTriggerImpl("recover_"
                    + instanceId + "_" + String.valueOf(dumId++),
                    Scheduler.DEFAULT_RECOVERY_GROUP, new Date(scheduledTime));
            rcvryTrig.setJobName(jobName);
            rcvryTrig.setJobGroup(jobGroup);
            rcvryTrig.setPriority(priority);
            rcvryTrig.setMisfireInstruction(SimpleTrigger.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY);

            JobDataMap jd = selectTriggerJobDataMap(conn, trigName, trigGroup);
            jd.put(Scheduler.FAILED_JOB_ORIGINAL_TRIGGER_NAME, trigName);
            jd.put(Scheduler.FAILED_JOB_ORIGINAL_TRIGGER_GROUP, trigGroup);
            jd.put(Scheduler.FAILED_JOB_ORIGINAL_TRIGGER_FIRETIME_IN_MILLISECONDS, String.valueOf(firedTime));
            jd.put(Scheduler.FAILED_JOB_ORIGINAL_TRIGGER_SCHEDULED_FIRETIME_IN_MILLISECONDS, String.valueOf(scheduledTime));
            rcvryTrig.setJobDataMap(jd);
            
            list.add(rcvryTrig);
        }
        return list;
    } finally {
        closeResultSet(rs);
        closeStatement(ps);
    }
}