Example usage for com.liferay.portal.kernel.scheduler SchedulerEngine DESTINATION_NAME

List of usage examples for com.liferay.portal.kernel.scheduler SchedulerEngine DESTINATION_NAME

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.scheduler SchedulerEngine DESTINATION_NAME.

Prototype

String DESTINATION_NAME

To view the source code for com.liferay.portal.kernel.scheduler SchedulerEngine DESTINATION_NAME.

Click Source Link

Usage

From source file:com.rivetlogic.quartz.util.QuartzSchedulerUtil.java

License:Open Source License

private static void runScheduledJob(String jobName, String groupName) {
    Message message = new Message();
    message.put(SchedulerEngine.MESSAGE_LISTENER_CLASS_NAME, jobName);
    message.put(SchedulerEngine.DESTINATION_NAME, DestinationNames.SCHEDULER_DISPATCH);
    message.put(SchedulerEngine.RECEIVER_KEY, new ReceiverKey(jobName, groupName));
    MessageBusUtil.sendMessage(DestinationNames.SCHEDULER_DISPATCH, message);
}

From source file:de.uhh.l2g.plugins.util.PortletScheduler.java

License:Open Source License

/**
 * Crowds this Scheduler with ResponseMessage Data Unique iff (jobName ==
 * schedulerClassName == groupName && storageType == STOR)
 * /*  w w w .  j a v a2 s.com*/
 * @return PortletScheduler
 */
public PortletScheduler assembleMessageFromResponses() {

    // These should be unique if everything is configured by liferay default
    try {
        List<SchedulerResponse> scheduledJobs = SchedulerEngineHelperUtil.getScheduledJobs();
        for (SchedulerResponse resp : scheduledJobs) {
            if (resp.getJobName().equalsIgnoreCase(this.schedulerClassName)) {
                this.setJobName(resp.getJobName());
                this.setGroupName(resp.getGroupName());
                this.setStorageType(resp.getStorageType());
                this.setDescription(resp.getDescription());
                this.setMessage(resp.getMessage());
                this.setTrigger(resp.getTrigger());

                if (this.getMessage() == null)
                    this.setMessage(new Message());
                LOG.debug("Job found. Copy Portlet Information: " + this.getMessage().toString());
                Map<String, Object> map = this.getMessage().getValues();

                // Fill this message with portlet specific data
                if (map.containsKey(SchedulerEngine.MESSAGE_LISTENER_CLASS_NAME))
                    this.getMessage().put(SchedulerEngine.MESSAGE_LISTENER_CLASS_NAME,
                            map.get(SchedulerEngine.MESSAGE_LISTENER_CLASS_NAME).toString());
                if (map.containsKey(SchedulerEngine.PORTLET_ID))
                    this.getMessage().put(SchedulerEngine.PORTLET_ID,
                            map.get(SchedulerEngine.PORTLET_ID).toString());
                if (map.containsKey(SchedulerEngine.MESSAGE_LISTENER_UUID))
                    this.getMessage().put(SchedulerEngine.MESSAGE_LISTENER_UUID,
                            map.get(SchedulerEngine.MESSAGE_LISTENER_UUID).toString());

                LOG.debug(this.getMessage().get(SchedulerEngine.DESTINATION_NAME) + " "
                        + this.getMessage().getDestinationName() + " "
                        + this.getMessage().getValues().get(SchedulerEngine.DESTINATION_NAME) + " "
                        + this.getMessage().getDestinationName());

                if (map.containsKey("MESSAGE_LISTENER_CLASS_NAME") && map.get("DESTINATION_NAME") != null) {
                    this.destination = map.get("DESTINATION_NAME").toString();
                    // this.getMessage().put(SchedulerEngine.DESTINATION_NAME,
                    // map.get("DESTINATION_NAME").toString());
                    this.getMessage().getValues().put(SchedulerEngine.DESTINATION_NAME,
                            map.get("DESTINATION_NAME").toString());
                    this.getMessage().setDestinationName(
                            this.getMessage().getValues().get(SchedulerEngine.DESTINATION_NAME).toString());
                } else {
                    LOG.debug("Destination not available yet. Setting to " + DEST);
                    this.destination = DEST;
                    // this.getMessage().put(SchedulerEngine.DESTINATION_NAME,
                    // DEST);
                    this.getMessage().getValues().put(SchedulerEngine.DESTINATION_NAME, DEST);
                    this.getMessage().setDestinationName(
                            this.getMessage().getValues().get(SchedulerEngine.DESTINATION_NAME).toString());
                }
                // new ReceiverKey(this.getJobName(), this.getGroupName())
                this.getMessage().put(SchedulerEngine.RECEIVER_KEY,
                        GetterUtil.getString(new ReceiverKey(this.getJobName(), this.getGroupName())));
                LOG.debug("ReceiverKey: " + new ReceiverKey(this.getJobName(), this.getGroupName()));
                TriggerState state = SchedulerEngineHelperUtil.getJobState(this.getJobName(),
                        this.getGroupName(), this.getStorageType());
                LOG.debug(state);
            }
        }
    } catch (SchedulerException e) {
        LOG.warn(e);
    }
    return this;
}

From source file:de.uhh.l2g.plugins.util.PortletScheduler.java

License:Open Source License

@Override
public void receive(Message message) throws MessageListenerException {
    String values = "No values";
    // Debug Information on running job
    if (message != null) {
        LOG.info("Message :" + message.toString());
        Thread thread = Thread.currentThread();
        LOG.info("Thread :" + thread.getContextClassLoader());
        LOG.info("Thread :" + thread.toString());
        Map<String, Object> map = message.getValues();
        LOG.info(message.get(SchedulerEngine.DESTINATION_NAME) + " " + message.getDestinationName() + " "
                + message.getValues().get(SchedulerEngine.DESTINATION_NAME) + " "
                + message.getDestinationName());
        values = map.toString();/*w  w w .j  a  va  2s.  c  o  m*/
    }
    LOG.info("Portlet Scheduler running... " + values);
}