Skip to content

Instantly share code, notes, and snippets.

@mac01021
Created July 24, 2015 21:27
Show Gist options
  • Select an option

  • Save mac01021/b0780377077758b663ab to your computer and use it in GitHub Desktop.

Select an option

Save mac01021/b0780377077758b663ab to your computer and use it in GitHub Desktop.
Simple connection error code
FetchRequest req = new FetchRequestBuilder()
.clientId(clientId)
.addFetch(topic, partition, offset, fetchSize)
.minBytes(1)
.maxWait(250)
.build();
FetchResponse resp = underlying.fetch(req);
if(resp.hasError()) {
int code = resp.errorCode(topic, partition);
if (code == 9) {
logger.warn("Fetch response contained error code: {}", resp.errorCode(topic, partition));
} else {
throw new RuntimeException(String.format("Fetch response contained error code %d", code));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment