@Override public void run(MessageReply rly) { SubmitLongJobReply reply = rly.castReply(); evt.setInventory(reply.getInventory()); evt.setNeedAudit(reply.isNeedAudit()); bus.publish(evt); } });
public static APISubmitLongJobEvent __example__() { APISubmitLongJobEvent event = new APISubmitLongJobEvent(); LongJobInventory inv = new LongJobInventory(); inv.setUuid(uuid()); event.setInventory(inv); event.setNeedAudit(false); return event; } }
private void validate(APISubmitLongJobMsg msg) { Class<APIMessage> apiClass = apiMsgOfLongJob.get(msg.getJobName()); if (null == apiClass) { throw new ApiMessageInterceptionException(argerr("%s is not an API", msg.getJobName())); } APIMessage jobMsg = JSONObjectUtil.toObject(msg.getJobData(), apiClass); jobMsg.setSession(msg.getSession()); try { jobMsg = apiMediator.getProcesser().process(jobMsg); // may throw ApiMessageInterceptionException } catch (StopRoutingException e) { // if got stop routing exception persist a success long job and return event success LongJobVO vo = createSuccessLongJob(msg); APISubmitLongJobEvent evt = new APISubmitLongJobEvent(msg.getId()); evt.setInventory(LongJobInventory.valueOf(vo)); evt.setNeedAudit(false); bus.publish(evt); throw e; } msg.setJobData(JSONObjectUtil.toJsonString(jobMsg)); // msg may be changed during validation }
private void validate(APIRerunLongJobMsg msg) { LongJobVO vo = Q.New(LongJobVO.class) .eq(LongJobVO_.uuid, msg.getUuid()) .find(); LongJobState state = vo.getState(); if (state != LongJobState.Succeeded && state != LongJobState.Canceled && state != LongJobState.Failed) { throw new ApiMessageInterceptionException(argerr("rerun longjob only when it's succeeded, canceled, or failed")); } Class<APIMessage> apiClass = apiMsgOfLongJob.get(vo.getJobName()); APIMessage jobMsg = JSONObjectUtil.toObject(vo.getJobData(), apiClass); jobMsg.setSession(msg.getSession()); try { apiMediator.getProcesser().process(jobMsg); // may throw ApiMessageInterceptionException } catch (StopRoutingException e) { APISubmitLongJobEvent evt = new APISubmitLongJobEvent(msg.getId()); evt.setInventory(LongJobInventory.valueOf(vo)); evt.setNeedAudit(false); bus.publish(evt); throw e; } dbf.updateAndRefresh(vo); }