-
FEATURED COMPONENTS
First time here? Check out the FAQ!
ZK 6.5 CE
Quartz 1.8.X
Resurrecting an old topic (discussed here http://www.zkoss.org/forum/listComment/18771 )
Scenario..
- user is working on system front end and submits job to do in background - job could be a few mins to a few hours.
- I am implementing a messaging system similar to zksample2, (thanks terrytornado et al) which will show messages to user when job is finished ..
- event queue is user based, so only that user receives message
- event queue is EventQueues.Application
I dont use the job itself to try to post to the event queue but a job listener.
The message is sent fine from the jobtoBeExecuted part of the listener interface.. (in essence the user gets message "Job is submitted")
From the jobWasExecuted, the part meant to say "Job is complete" however I have got various errors relating to
- server push not enabled
- no execution available/Not in an execution
I dont have comet push available to me as using ZK CE.
Thanks for any pointers
Daniel
public void jobToBeExecuted(JobExecutionContext inContext) { // eventQueue = null; sendEventQueueMessage(inContext.getJobDetail().getJobDataMap(), inContext.getJobDetail().getName(), Labels.getLabel("eventQueue_JobSubmitted")); } public void jobWasExecuted(JobExecutionContext inContext, JobExecutionException inException) { logger.debug(">>> jobWasExecuted"); sendEventQueueMessage(inContext.getJobDetail().getJobDataMap(), inContext.getJobDetail().getName(), Labels.getLabel("eventQueue_JobSubmitted")); try { if (_desktop.isServerPushEnabled()) { Executions.activate(_desktop); Clients.clearBusy(); Executions.deactivate(_desktop); } } catch (Exception ex) { logger.error("Error in completing job veto " + ex.getMessage()); } finally { _desktop.enableServerPush(false); } } private void sendEventQueueMessage(JobDataMap dataMap, String jobName, String message) { try { String userName = null; if (dataMap.containsKey("submittedUserName")) { userName = (String) dataMap.get("submittedUserName"); Desktop thisDesktop = (Desktop) dataMap.get("_desktop"); if (thisDesktop != null) { if (eventQueue == null) { logger.debug("Create queue"); eventQueue = EventQueues.lookup("User_" + userName + "_EventQueue", EventQueues.APPLICATION, true); } if (!thisDesktop.isServerPushEnabled()) { logger.debug("Enable push " + thisDesktop.isAlive()); thisDesktop.enableServerPush(true); } Executions.activate(_desktop); eventQueue.publish(new Event("onChangeSelectedObject", null, jobName + "> " + message)); Executions.deactivate(_desktop); // _desktop.enableServerPush(false); } } } catch (Exception ex) { logger.error("Error in sending to event queue " + ex.getMessage()); } } }
for a first quick help: please read about Gekkio's AtmosphereServerPush. https://github.com/Gekkio/jawwa
best
Stephan
Thanks Stephan
I'll review that and see if it helps me understand some more.
Daniel
it runs in all editions.
Asked: 2012-10-15 14:03:57 +0800
Seen: 98 times
Last updated: Oct 16 '12