示例#1
0
 public void checkSequenceNumber(Message m) {
   if (m.getEnvelope().getRoutingKey().contains("sync")) {
     TrainInfo ti = g.fromJson(m.getJsonBody(), TrainInfo.class);
     logger.info(String.valueOf(System.currentTimeMillis() - ti.getTimeStamp()));
     if (ti.getSequenceNumber() != syncSeq.get(ti.getId())) {
       logger.error(
           "Expected packet with seqnr. "
               + syncSeq.get(ti.getId())
               + " got "
               + ti.getSequenceNumber());
     }
     syncSeq.put(ti.getId(), ti.getSequenceNumber() + 1);
   } else {
     TrainInfoUpdate tu = g.fromJson(m.getJsonBody(), TrainInfoUpdate.class);
     logger.info(String.valueOf(System.currentTimeMillis() - tu.getTimeStamp()));
     if (tu.getSequenceNumber() != updateSeq.get(tu.getId())) {
       logger.error(
           "Expected packet with seqnr. "
               + syncSeq.get(tu.getId())
               + " got "
               + tu.getSequenceNumber());
     }
     updateSeq.put(tu.getId(), tu.getSequenceNumber() + 1);
   }
 }
示例#2
0
 public void printTimeDifference(Message m) {
   if (m.getEnvelope().getRoutingKey().contains("sync")) {
     TrainInfo ti = g.fromJson(m.getJsonBody(), TrainInfo.class);
     logger.info(String.valueOf(System.currentTimeMillis() - ti.getTimeStamp()));
   } else {
     TrainInfoUpdate tu = g.fromJson(m.getJsonBody(), TrainInfoUpdate.class);
     logger.info(String.valueOf(System.currentTimeMillis() - tu.getTimeStamp()));
   }
 }