1717import java .util .Map ;
1818import java .util .Optional ;
1919import java .util .Set ;
20- import java .util .concurrent .ExecutorService ;
20+ import java .util .concurrent .Executor ;
2121import java .util .concurrent .Executors ;
2222import java .util .concurrent .RejectedExecutionException ;
2323import java .util .concurrent .ScheduledExecutorService ;
@@ -42,7 +42,7 @@ public class NSQConsumer implements Closeable {
4242 private int messagesPerBatch = 200 ;
4343 private long lookupPeriod = 60 * 1000 ; // how often to recheck for new nodes (and clean up non responsive nodes)
4444 private ScheduledExecutorService scheduler = Executors .newSingleThreadScheduledExecutor ();
45- private ExecutorService executor = Executors .newCachedThreadPool ();
45+ private Executor executor = Executors .newCachedThreadPool ();
4646 private Optional <ScheduledFuture <?>> timeout = Optional .empty ();
4747
4848 public NSQConsumer (final NSQLookup lookup , final String topic , final String channel , final NSQMessageCallback callback ) {
@@ -184,7 +184,7 @@ public NSQConsumer setLookupPeriod(final long periodMillis) {
184184 private void connect () {
185185 for (final Iterator <Map .Entry <ServerAddress , Connection >> it = connections .entrySet ().iterator (); it .hasNext (); ) {
186186 Connection cnn = it .next ().getValue ();
187- if (!cnn .isConnected () || !cnn .isHeartbeatStatusOK ()){
187+ if (!cnn .isConnected () || !cnn .isHeartbeatStatusOK ()) {
188188 //force close
189189 cnn .close ();
190190 it .remove ();
@@ -227,7 +227,7 @@ public long getTotalMessages() {
227227 * The executer can only changed before the client is started.
228228 * Default is a cached threadpool.
229229 */
230- public NSQConsumer setExecutor (final ExecutorService executor ) {
230+ public NSQConsumer setExecutor (final Executor executor ) {
231231 if (!started ) {
232232 this .executor = executor ;
233233 }
0 commit comments