Skip to content

Commit c9dceaf

Browse files
Will Drostebrainlag
authored andcommitted
Use Executor instead of ExecutorService for simplier use
(cherry picked from commit b9f8393)
1 parent a35650e commit c9dceaf

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/main/java/com/github/brainlag/nsq/NSQConsumer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import java.util.Map;
1818
import java.util.Optional;
1919
import java.util.Set;
20-
import java.util.concurrent.ExecutorService;
20+
import java.util.concurrent.Executor;
2121
import java.util.concurrent.Executors;
2222
import java.util.concurrent.RejectedExecutionException;
2323
import 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

Comments
 (0)