Skip to content

Instantly share code, notes, and snippets.

@skimbrel
Created July 23, 2015 17:34
Show Gist options
  • Save skimbrel/10d8dde3e82ef34995b9 to your computer and use it in GitHub Desktop.
Save skimbrel/10d8dde3e82ef34995b9 to your computer and use it in GitHub Desktop.
AWS client code. Ah, yes, the "dispatch async error handler then throw the exception anyway" pattern.
public Future<DeleteMessageBatchResult> deleteMessageBatchAsync(
final DeleteMessageBatchRequest deleteMessageBatchRequest,
final AsyncHandler<DeleteMessageBatchRequest, DeleteMessageBatchResult> asyncHandler)
throws AmazonServiceException, AmazonClientException {
return executorService.submit(new Callable<DeleteMessageBatchResult>() {
public DeleteMessageBatchResult call() throws Exception {
DeleteMessageBatchResult result;
try {
result = deleteMessageBatch(deleteMessageBatchRequest);
} catch (Exception ex) {
asyncHandler.onError(ex);
throw ex;
}
asyncHandler.onSuccess(deleteMessageBatchRequest, result);
return result;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment