arp.process.synchronization.ThreadProcessSyncFinishMessageConsumer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ARP Show documentation
Show all versions of ARP Show documentation
a java development framework with aggregation, repository and process
The newest version!
package arp.process.synchronization;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import arp.process.publish.Message;
import arp.process.publish.ProcessMessageReceiver;
public class ThreadProcessSyncFinishMessageConsumer {
private ProcessMessageReceiver receiver;
private ExecutorService executorService;
public ThreadProcessSyncFinishMessageConsumer(
ProcessMessageReceiver receiver) {
this.receiver = receiver;
executorService = Executors.newCachedThreadPool();
}
public void start() {
new Thread(
() -> {
while (true) {
List msgList = null;
try {
msgList = receiver.receive();
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
if (msgList == null) {
continue;
}
for (Message msg : msgList) {
executorService
.submit(() -> {
List