Skip to content

Instantly share code, notes, and snippets.

@mzimecki
Created May 27, 2017 18:50
Show Gist options
  • Save mzimecki/e46b0c70b167925486569445f69e1512 to your computer and use it in GitHub Desktop.
Save mzimecki/e46b0c70b167925486569445f69e1512 to your computer and use it in GitHub Desktop.
Redelivery processor
public class RedeliveryProcessor implements Processor {
private static final int MAX_REDELIVERIES = 5;
@Override
public void process(Exchange exchange) throws Exception {
final int redeliveryCount = exchange.getIn().getHeader(ServiceConstants.REDELIVERY_COUNT_HEADER_NAME, Integer.class).intValue();
if (redeliveryCount <= MAX_REDELIVERIES) {
exchange.getIn().setHeader(ServiceConstants.REDELIVERY_COUNT_HEADER_NAME, redeliveryCount + 1);
} else {
exchange.setProperty(Exchange.ROUTE_STOP, Boolean.TRUE);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment