mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-17 00:59:11 +00:00
docs: update queue-based load leveling
This commit is contained in:
@@ -90,7 +90,7 @@ public class App {
|
||||
final var srvRunnable = new ServiceExecutor(msgQueue);
|
||||
|
||||
// Create a ThreadPool of 2 threads and
|
||||
// submit all Runnable task for execution to executor..
|
||||
// submit all Runnable task for execution to executor
|
||||
executor = Executors.newFixedThreadPool(2);
|
||||
executor.submit(taskRunnable1);
|
||||
executor.submit(taskRunnable2);
|
||||
|
||||
+2
-2
@@ -48,7 +48,7 @@ public class ServiceExecutor implements Runnable {
|
||||
var msg = msgQueue.retrieveMsg();
|
||||
|
||||
if (null != msg) {
|
||||
LOGGER.info(msg.toString() + " is served.");
|
||||
LOGGER.info(msg + " is served.");
|
||||
} else {
|
||||
LOGGER.info("Service Executor: Waiting for Messages to serve .. ");
|
||||
}
|
||||
@@ -59,4 +59,4 @@ public class ServiceExecutor implements Runnable {
|
||||
LOGGER.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ package com.iluwatar.queue.load.leveling;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* TaskGenerator class. Each TaskGenerator thread will be a Worker which submit's messages to the
|
||||
* TaskGenerator class. Each TaskGenerator thread will be a Worker which submits messages to the
|
||||
* queue. We need to mention the message count for each of the TaskGenerator threads.
|
||||
*/
|
||||
@Slf4j
|
||||
|
||||
+2
-3
@@ -24,10 +24,9 @@
|
||||
*/
|
||||
package com.iluwatar.queue.load.leveling;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Test case for submitting Message to Blocking Queue by TaskGenerator and retrieve the message by
|
||||
|
||||
Reference in New Issue
Block a user