1 18 package org.apache.activemq.transport.reliable; 19 20 import java.io.IOException ; 21 22 28 public class ExceptionIfDroppedReplayStrategy implements ReplayStrategy { 29 30 private int maximumDifference = 5; 31 32 public ExceptionIfDroppedReplayStrategy() { 33 } 34 35 public ExceptionIfDroppedReplayStrategy(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 throw new IOException ("Packets dropped on: " + transport + " count: " + count + " expected: " + expectedCounter + " but was: " + actualCounter); 44 } 45 46 return difference > 0; 48 } 49 50 public void onReceivedPacket(ReliableTransport transport, long expectedCounter) { 51 } 52 53 public int getMaximumDifference() { 54 return maximumDifference; 55 } 56 57 61 public void setMaximumDifference(int maximumDifference) { 62 this.maximumDifference = maximumDifference; 63 } 64 65 } 66 | Popular Tags |