public void onMessage(Message message) { ObjectMessage om = (ObjectMessage) message; try { PPSOrder order = (PPSOrder) om.getObject(); log.info("Start processing " + order); try { sendPPS(order.isCreate(), order.getDataset(), order.getDestination()); log.info("Finished processing " + order); } catch (Exception e) { order.setThrowable(e); final int failureCount = order.getFailureCount() + 1; order.setFailureCount(failureCount); final long delay = retryIntervalls.getIntervall(failureCount); if (delay == -1L) { log.error("Give up to process " + order, e); jmsDelegate.fail(queueName, order); } else { log.warn("Failed to process " + order + ". Scheduling retry.", e); jmsDelegate.queue(queueName, order, 0, System.currentTimeMillis() + delay); } } } catch (JMSException e) { log.error("jms error during processing message: " + message, e); } catch (Throwable e) { log.error("unexpected error during processing message: " + message, e); } }
protected void schedule(DeleteStudyOrder order, long scheduledTime) throws Exception { if (srcFsGroup == null || destFsGroup == null) { String msg = "FileMove service is disabled! Set SourceFileSystemGroupID and DestinationFileSystemGroupID to enable it."; log.info(msg); throw new RuntimeException(msg); } else if ("ERROR".equals(getUsableDiskSpaceStringOnDest())) { String msg = "UsableDiskSpaceStringOnDest reports an error! Scheduling Move Order cancelled! Please check DestinationFileSystemGroupID configuration!"; log.error(msg); throw new RuntimeException(msg); } else { if (log.isInfoEnabled()) { String scheduledTimeStr = scheduledTime > 0 ? new Date(scheduledTime).toString() : "now"; log.info( "Scheduling job [" + order + "] at " + scheduledTimeStr + ". Retry times: " + order.getFailureCount()); } jmsDelegate.queue(moveFilesOfStudyQueueName, order, Message.DEFAULT_PRIORITY, scheduledTime); } }
public void handleNotification(Notification notif, Object handback) { String spsuid = (String) notif.getUserData(); Dataset pps = DcmObjectFactory.getInstance().newDataset(); try { Dataset sps; GPWLManager gpwlmgr = getGPWLManager(); sps = gpwlmgr.getWorklistItem(spsuid); String ppsiuid = spsuid + ppsuidSuffix; String status = sps.getString(Tags.GPSPSStatus); pps.putCS(Tags.GPPPSStatus, status); pps.putUI(Tags.SOPInstanceUID, ppsiuid); Date now = new Date(); if ("IN PROGRESS".equals(status)) { try { getGPPPSManager().getGPPPS(ppsiuid); return; // avoid duplicate N_CREATE } catch (Exception e) { } pps.putSH(Tags.PPSID, "PPS" + ppsiuid.hashCode()); pps.putDA(Tags.PPSStartDate, now); pps.putTM(Tags.PPSStartTime, now); pps.putDA(Tags.PPSEndDate); pps.putTM(Tags.PPSEndTime); for (int i = 0; i < N_CREATE_TYPE2_ATTRS.length; i++) { pps.putXX(N_CREATE_TYPE2_ATTRS[i]); } pps.putAll(sps.subSet(N_CREATE_SPS_ATTRS)); copyCode( copyWorkitemCode, sps.getItem(Tags.ScheduledWorkitemCodeSeq), pps.putSQ(Tags.PerformedWorkitemCodeSeq)); copyCode( copyStationNameCode, sps.getItem(Tags.ScheduledStationNameCodeSeq), pps.putSQ(Tags.PerformedStationNameCodeSeq)); copyCode( copyStationClassCode, sps.getItem(Tags.ScheduledStationClassCodeSeq), pps.putSQ(Tags.PerformedStationClassCodeSeq)); copyCode( copyStationGeographicLocationCode, sps.getItem(Tags.ScheduledStationGeographicLocationCodeSeq), pps.putSQ(Tags.PerformedStationGeographicLocationCodeSeq)); copyCode( copyProcessingApplicationsCode, sps.getItem(Tags.ScheduledProcessingApplicationsCodeSeq), pps.putSQ(Tags.PerformedProcessingApplicationsCodeSeq)); } else if ("COMPLETED".equals(status) || "DISCONTINUED".equals(status)) { pps.putDA(Tags.PPSEndDate, now); pps.putTM(Tags.PPSEndTime, now); pps.putAll(gpwlmgr.getOutputInformation(spsuid)); } else { return; } } catch (Exception e) { log.error("Failed to access GP-SPS[" + spsuid + "]", e); return; } for (int i = 0; i < destAETs.length; i++) { PPSOrder order = new PPSOrder(pps, destAETs[i]); try { log.info("Scheduling " + order); jmsDelegate.queue(queueName, order, Message.DEFAULT_PRIORITY, 0L); } catch (Exception e) { log.error("Failed to schedule " + order, e); } } }