Skip to content

Instantly share code, notes, and snippets.

Created July 23, 2015 17:34
What would you like to do?
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) {
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