@Test public void testMetaReceived() throws Exception{ SFRMMessage message = new SFRMMessage(); message.setSegmentType(SFRMConstant.MSGT_META); message.setPartnershipId("loopback"); message.setMessageID("testMetaReceivd"); message.setFilename("filename.tar"); message.setTotalSize(1024); message.setSegmentNo(0); inHandler.processIncomingMessage(message, null); SFRMMessageDAO dao = (SFRMMessageDAO) sfrmProcessor.getDAOFactory().createDAO(SFRMMessageDAO.class); SFRMMessageDVO dvo = (SFRMMessageDVO) dao.createDVO(); dvo.setMessageId("testMetaReceivd"); dvo.setMessageBox(SFRMConstant.MSGBOX_IN); assertTrue("Message testMetaReceivd was not inserted", dao.retrieve(dvo)); assertEquals("Filename should be: filename.tar", "filename.tar", dvo.getFilename()); assertEquals("Partnership ID should be loopback", "loopback", dvo.getPartnershipId()); assertEquals("Payload size should be 1024", 1024, dvo.getTotalSize()); Thread.sleep(1000); dvo = (SFRMMessageDVO) dao.createDVO(); dvo.setMessageId("testMetaReceivd"); dvo.setMessageBox(SFRMConstant.MSGBOX_IN); dao.retrieve(dvo); assertEquals("Message status should be PR", "PR", dvo.getStatus()); File inRepo = sfrmProcessor.getIncomingRepository().getRepository(); File payload = new File(inRepo, "~loopback$testMetaReceivd.sfrm"); System.out.println(payload.getCanonicalPath()); assertTrue("Dummy payload wasn't created", payload.exists()); }
public SFRMMessage processIncomingMessage(SFRMMessage incomingMessage, final Object[] params) throws Exception { final SFRMMessage inputMessage = incomingMessage; final SFRMMessageClassifier mc = incomingMessage.getClassifier(); final SFRMPartnershipDVO pDVO; SFRMMessage retMessage = null; try{ SFRMLogUtil.log(SFRMLog.IMH_CALLER, SFRMLog.RECEIVE_SGT, inputMessage.getMessageID(), inputMessage.getSegmentNo()); if (this.initGuardForSegment (inputMessage)) return null; pDVO = this.extractPartnership(inputMessage); this.unpackIncomingMessage(inputMessage, pDVO); if (mc.isMeta()) { this.processHandshakingMessage(inputMessage, params); } else if (mc.isAcknowledgementRequest()){ retMessage = this.processAcknowledgement(inputMessage, pDVO); this.releaseGuardForSegment(inputMessage); return retMessage; } else { boolean isProc = this.isProcessingMessage(inputMessage); if (!isProc) throw new SFRMMessageException("Message is not processing, ignore segments."); } if (mc.isPayload()){ boolean isDuplicate = this.isDuplicateSegment(inputMessage); if(isDuplicate) return null; } final IncomingMessageHandler owner = this; ActiveThread thread = null; try { thread = monitor.acquireThread(); if (thread == null) return null; thread.setTask(new ActiveTaskAdaptor() { public void execute() throws Exception { try{ if (!owner.resolveGuardOwnerForSegment(inputMessage)) return; SFRMLogUtil.debug(SFRMLog.IMH_CALLER, SFRMLog.SPANNED_THRD, inputMessage.getSegmentType()); if (mc.isPayload()){ owner.processSegmentMessage (inputMessage, params); } else if (mc.isMeta()){ owner.processMetaMessage (inputMessage, pDVO, params); } } finally { owner.releaseGuardForSegment(inputMessage); } getLogger().debug(SFRMLog.IMH_CALLER + "Message info" + inputMessage); } public void onFailure(Throwable e) { getLogger().error(SFRMLog.IMH_CALLER + "Error", e); } }); thread.start(); } catch (Throwable e) { monitor.releaseThread(thread); } } catch(Exception ex){ this.releaseGuardForSegment(inputMessage); throw ex; } return retMessage; }
IncomingMessageHandler extends SFRMComponent { public SFRMMessage processIncomingMessage(SFRMMessage incomingMessage, final Object[] params) throws Exception { final SFRMMessage inputMessage = incomingMessage; final SFRMMessageClassifier mc = incomingMessage.getClassifier(); final SFRMPartnershipDVO pDVO; SFRMMessage retMessage = null; try{ SFRMLogUtil.log(SFRMLog.IMH_CALLER, SFRMLog.RECEIVE_SGT, inputMessage.getMessageID(), inputMessage.getSegmentNo()); if (this.initGuardForSegment (inputMessage)) return null; pDVO = this.extractPartnership(inputMessage); this.unpackIncomingMessage(inputMessage, pDVO); if (mc.isMeta()) { this.processHandshakingMessage(inputMessage, params); } else if (mc.isAcknowledgementRequest()){ retMessage = this.processAcknowledgement(inputMessage, pDVO); this.releaseGuardForSegment(inputMessage); return retMessage; } else { boolean isProc = this.isProcessingMessage(inputMessage); if (!isProc) throw new SFRMMessageException("Message is not processing, ignore segments."); } if (mc.isPayload()){ boolean isDuplicate = this.isDuplicateSegment(inputMessage); if(isDuplicate) return null; } final IncomingMessageHandler owner = this; ActiveThread thread = null; try { thread = monitor.acquireThread(); if (thread == null) return null; thread.setTask(new ActiveTaskAdaptor() { public void execute() throws Exception { try{ if (!owner.resolveGuardOwnerForSegment(inputMessage)) return; SFRMLogUtil.debug(SFRMLog.IMH_CALLER, SFRMLog.SPANNED_THRD, inputMessage.getSegmentType()); if (mc.isPayload()){ owner.processSegmentMessage (inputMessage, params); } else if (mc.isMeta()){ owner.processMetaMessage (inputMessage, pDVO, params); } } finally { owner.releaseGuardForSegment(inputMessage); } getLogger().debug(SFRMLog.IMH_CALLER + "Message info" + inputMessage); } public void onFailure(Throwable e) { getLogger().error(SFRMLog.IMH_CALLER + "Error", e); } }); thread.start(); } catch (Throwable e) { monitor.releaseThread(thread); } } catch(Exception ex){ this.releaseGuardForSegment(inputMessage); throw ex; } return retMessage; } }
IncomingMessageHandler extends SFRMComponent { public SFRMMessage processIncomingMessage(SFRMMessage incomingMessage, final Object[] params) throws Exception { final SFRMMessage inputMessage = incomingMessage; final SFRMMessageClassifier mc = incomingMessage.getClassifier(); final SFRMPartnershipDVO pDVO; SFRMMessage retMessage = null; try{ SFRMLogUtil.log(SFRMLog.IMH_CALLER, SFRMLog.RECEIVE_SGT, inputMessage.getMessageID(), inputMessage.getSegmentNo()); if (this.initGuardForSegment (inputMessage)) return null; pDVO = this.extractPartnership(inputMessage); this.unpackIncomingMessage(inputMessage, pDVO); if (mc.isMeta()) { this.processHandshakingMessage(inputMessage, params); } else if (mc.isAcknowledgementRequest()){ retMessage = this.processAcknowledgement(inputMessage, pDVO); this.releaseGuardForSegment(inputMessage); return retMessage; } else { boolean isProc = this.isProcessingMessage(inputMessage); if (!isProc) throw new SFRMMessageException("Message is not processing, ignore segments."); } if (mc.isPayload()){ boolean isDuplicate = this.isDuplicateSegment(inputMessage); if(isDuplicate) return null; } final IncomingMessageHandler owner = this; ActiveThread thread = null; try { thread = monitor.acquireThread(); if (thread == null) return null; thread.setTask(new ActiveTaskAdaptor() { public void execute() throws Exception { try{ if (!owner.resolveGuardOwnerForSegment(inputMessage)) return; SFRMLogUtil.debug(SFRMLog.IMH_CALLER, SFRMLog.SPANNED_THRD, inputMessage.getSegmentType()); if (mc.isPayload()){ owner.processSegmentMessage (inputMessage, params); } else if (mc.isMeta()){ owner.processMetaMessage (inputMessage, pDVO, params); } } finally { owner.releaseGuardForSegment(inputMessage); } getLogger().debug(SFRMLog.IMH_CALLER + "Message info" + inputMessage); } public void onFailure(Throwable e) { getLogger().error(SFRMLog.IMH_CALLER + "Error", e); } }); thread.start(); } catch (Throwable e) { monitor.releaseThread(thread); } } catch(Exception ex){ this.releaseGuardForSegment(inputMessage); throw ex; } return retMessage; }  }
IncomingMessageHandler extends SFRMComponent { public SFRMMessage processIncomingMessage(SFRMMessage incomingMessage, final Object[] params) throws Exception { final SFRMMessage inputMessage = incomingMessage; final SFRMMessageClassifier mc = incomingMessage.getClassifier(); final SFRMPartnershipDVO pDVO; SFRMMessage retMessage = null; try{ SFRMLogUtil.log(SFRMLog.IMH_CALLER, SFRMLog.RECEIVE_SGT, inputMessage.getMessageID(), inputMessage.getSegmentNo()); if (this.initGuardForSegment (inputMessage)) return null; pDVO = this.extractPartnership(inputMessage); this.unpackIncomingMessage(inputMessage, pDVO); if (mc.isMeta()) { this.processHandshakingMessage(inputMessage, params); } else if (mc.isAcknowledgementRequest()){ retMessage = this.processAcknowledgement(inputMessage, pDVO); this.releaseGuardForSegment(inputMessage); return retMessage; } else { boolean isProc = this.isProcessingMessage(inputMessage); if (!isProc) throw new SFRMMessageException("Message is not processing, ignore segments."); } if (mc.isPayload()){ boolean isDuplicate = this.isDuplicateSegment(inputMessage); if(isDuplicate) return null; } final IncomingMessageHandler owner = this; ActiveThread thread = null; try { thread = monitor.acquireThread(); if (thread == null) return null; thread.setTask(new ActiveTaskAdaptor() { public void execute() throws Exception { try{ if (!owner.resolveGuardOwnerForSegment(inputMessage)) return; SFRMLogUtil.debug(SFRMLog.IMH_CALLER, SFRMLog.SPANNED_THRD, inputMessage.getSegmentType()); if (mc.isPayload()){ owner.processSegmentMessage (inputMessage, params); } else if (mc.isMeta()){ owner.processMetaMessage (inputMessage, pDVO, params); } } finally { owner.releaseGuardForSegment(inputMessage); } getLogger().debug(SFRMLog.IMH_CALLER + "Message info" + inputMessage); } public void onFailure(Throwable e) { getLogger().error(SFRMLog.IMH_CALLER + "Error", e); } }); thread.start(); } catch (Throwable e) { monitor.releaseThread(thread); } } catch(Exception ex){ this.releaseGuardForSegment(inputMessage); throw ex; } return retMessage; }  static IncomingMessageHandler getInstance(); SFRMPartnershipDVO extractPartnership(SFRMMessage incomingMessage); boolean isDuplicateSegment(SFRMMessage incomingMessage); boolean isProcessingMessage(SFRMMessage incomingMessage); boolean isNotEnoughRoom(SFRMMessage incomingMessage, long threshold); void unpackIncomingMessage(SFRMMessage message, SFRMPartnershipDVO partnershipDVO); boolean initGuardForSegment(final SFRMMessage incomingMessage); boolean resolveGuardOwnerForSegment(final SFRMMessage incomingMessage); boolean releaseGuardForSegment(final SFRMMessage incomingMessage); SFRMMessage processIncomingMessage(SFRMMessage incomingMessage, final Object[] params); SFRMMessage processHandshakingMessage(
			SFRMMessage 		rawMessage,
			final Object[] 		params); SFRMMessage processMetaMessage(
			SFRMMessage 		inputMessage,
			SFRMPartnershipDVO 	partnershipDVO, 
			final Object[] 		params); SFRMMessage processSegmentMessage(SFRMMessage rawMessage, final Object[] params); SFRMMessage processAcknowledgement(SFRMMessage msg, SFRMPartnershipDVO pDVO); String processPRAck(SFRMMessageDVO mDVO, SFRMAcknowledgementParser parser); String processPDFAck(SFRMMessageDVO mDVO); String processPPSAck(SFRMMessageDVO mDVO); String processPSDAck(SFRMMessageDVO mDVO); String processPRSAck(SFRMMessageDVO mDVO); }
IncomingMessageHandler extends SFRMComponent { public SFRMMessage processIncomingMessage(SFRMMessage incomingMessage, final Object[] params) throws Exception { final SFRMMessage inputMessage = incomingMessage; final SFRMMessageClassifier mc = incomingMessage.getClassifier(); final SFRMPartnershipDVO pDVO; SFRMMessage retMessage = null; try{ SFRMLogUtil.log(SFRMLog.IMH_CALLER, SFRMLog.RECEIVE_SGT, inputMessage.getMessageID(), inputMessage.getSegmentNo()); if (this.initGuardForSegment (inputMessage)) return null; pDVO = this.extractPartnership(inputMessage); this.unpackIncomingMessage(inputMessage, pDVO); if (mc.isMeta()) { this.processHandshakingMessage(inputMessage, params); } else if (mc.isAcknowledgementRequest()){ retMessage = this.processAcknowledgement(inputMessage, pDVO); this.releaseGuardForSegment(inputMessage); return retMessage; } else { boolean isProc = this.isProcessingMessage(inputMessage); if (!isProc) throw new SFRMMessageException("Message is not processing, ignore segments."); } if (mc.isPayload()){ boolean isDuplicate = this.isDuplicateSegment(inputMessage); if(isDuplicate) return null; } final IncomingMessageHandler owner = this; ActiveThread thread = null; try { thread = monitor.acquireThread(); if (thread == null) return null; thread.setTask(new ActiveTaskAdaptor() { public void execute() throws Exception { try{ if (!owner.resolveGuardOwnerForSegment(inputMessage)) return; SFRMLogUtil.debug(SFRMLog.IMH_CALLER, SFRMLog.SPANNED_THRD, inputMessage.getSegmentType()); if (mc.isPayload()){ owner.processSegmentMessage (inputMessage, params); } else if (mc.isMeta()){ owner.processMetaMessage (inputMessage, pDVO, params); } } finally { owner.releaseGuardForSegment(inputMessage); } getLogger().debug(SFRMLog.IMH_CALLER + "Message info" + inputMessage); } public void onFailure(Throwable e) { getLogger().error(SFRMLog.IMH_CALLER + "Error", e); } }); thread.start(); } catch (Throwable e) { monitor.releaseThread(thread); } } catch(Exception ex){ this.releaseGuardForSegment(inputMessage); throw ex; } return retMessage; }  static IncomingMessageHandler getInstance(); SFRMPartnershipDVO extractPartnership(SFRMMessage incomingMessage); boolean isDuplicateSegment(SFRMMessage incomingMessage); boolean isProcessingMessage(SFRMMessage incomingMessage); boolean isNotEnoughRoom(SFRMMessage incomingMessage, long threshold); void unpackIncomingMessage(SFRMMessage message, SFRMPartnershipDVO partnershipDVO); boolean initGuardForSegment(final SFRMMessage incomingMessage); boolean resolveGuardOwnerForSegment(final SFRMMessage incomingMessage); boolean releaseGuardForSegment(final SFRMMessage incomingMessage); SFRMMessage processIncomingMessage(SFRMMessage incomingMessage, final Object[] params); SFRMMessage processHandshakingMessage(
			SFRMMessage 		rawMessage,
			final Object[] 		params); SFRMMessage processMetaMessage(
			SFRMMessage 		inputMessage,
			SFRMPartnershipDVO 	partnershipDVO, 
			final Object[] 		params); SFRMMessage processSegmentMessage(SFRMMessage rawMessage, final Object[] params); SFRMMessage processAcknowledgement(SFRMMessage msg, SFRMPartnershipDVO pDVO); String processPRAck(SFRMMessageDVO mDVO, SFRMAcknowledgementParser parser); String processPDFAck(SFRMMessageDVO mDVO); String processPPSAck(SFRMMessageDVO mDVO); String processPSDAck(SFRMMessageDVO mDVO); String processPRSAck(SFRMMessageDVO mDVO);  }