1 18 package org.apache.activemq.transport.reliable; 19 20 import java.io.IOException ; 21 22 28 public class DefaultReplayStrategy implements ReplayStrategy { 29 30 private int maximumDifference = 5; 31 32 public DefaultReplayStrategy() { 33 } 34 35 public DefaultReplayStrategy(int maximumDifference) { 36 this.maximumDifference = maximumDifference; 37 } 38 39 public boolean onDroppedPackets(ReliableTransport transport, int expectedCounter, int actualCounter, int nextAvailableCounter) throws IOException { 40 int difference = actualCounter - expectedCounter; 41 long count = Math.abs(difference); 42 if (count > maximumDifference) { 43 int upperLimit = actualCounter - 1; 44 if (upperLimit < expectedCounter) { 45 upperLimit = expectedCounter; 46 } 47 transport.requestReplay(expectedCounter, upperLimit); 48 } 49 50 return difference > 0; 52 } 53 54 public void onReceivedPacket(ReliableTransport transport, long expectedCounter) { 55 } 57 58 public int getMaximumDifference() { 59 return maximumDifference; 60 } 61 62 66 public void setMaximumDifference(int maximumDifference) { 67 this.maximumDifference = maximumDifference; 68 } 69 70 } 71 | Popular Tags |