Skip to content

Commit

Permalink
Merge pull request #889 from mattrjacobs/request-batch-unsafe-subscribe
Browse files Browse the repository at this point in the history
RequestBatch can use unsafeSubscribe with an empty Subscriber instead of paying cost of subscribe()
  • Loading branch information
mattrjacobs committed Sep 9, 2015
2 parents 317eaa9 + 2684332 commit 970348b
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.netflix.hystrix.HystrixCollapser;
import com.netflix.hystrix.HystrixCollapser.CollapsedRequest;
import com.netflix.hystrix.HystrixCollapserProperties;
import rx.observers.Subscribers;

/**
* A batch of requests collapsed together by a RequestCollapser instance. When full or time has expired it will execute and stop accepting further submissions.
Expand Down Expand Up @@ -160,14 +161,14 @@ public void call() {
Exception e = null;
for (CollapsedRequest<ResponseType, RequestArgumentType> request : shardRequests) {
try {
e = ((CollapsedRequestObservableFunction<ResponseType, RequestArgumentType>) request).setExceptionIfResponseNotReceived(e,"No response set by " + commandCollapser.getCollapserKey().name() + " 'mapResponseToRequests' implementation.");
e = ((CollapsedRequestObservableFunction<ResponseType, RequestArgumentType>) request).setExceptionIfResponseNotReceived(e, "No response set by " + commandCollapser.getCollapserKey().name() + " 'mapResponseToRequests' implementation.");
} catch (IllegalStateException e2) {
logger.debug("Partial success of 'mapResponseToRequests' resulted in IllegalStateException while setting 'No response set' Exception. Continuing ... ", e2);
}
}
}

}).subscribe();
}).unsafeSubscribe(Subscribers.empty());

} catch (Exception e) {
logger.error("Exception while creating and queueing command with batch.", e);
Expand Down

0 comments on commit 970348b

Please sign in to comment.