org.zstacks.zbus.client.service.Service Maven / Gradle / Ivy
package org.zstacks.zbus.client.service;
import java.io.Closeable;
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.zstacks.zbus.client.Consumer;
import org.zstacks.znet.Message;
public class Service implements Closeable {
private static final Logger log = LoggerFactory.getLogger(Service.class);
private final ServiceConfig config;
private WorkerThread[] workerThreads;
public Service(ServiceConfig config){
this.config = config;
if(config.getMq() == null || "".equals(config.getMq())){
throw new IllegalArgumentException("MQ required");
}
if(config.getServiceHandler() == null){
throw new IllegalArgumentException("serviceHandler required");
}
}
@Override
public void close() throws IOException {
if(this.workerThreads != null){
for(WorkerThread thread : this.workerThreads){
try {
thread.close();
} catch (IOException e) {
log.debug(e.getMessage(), e);
}
}
}
}
public void start(){
this.workerThreads = new WorkerThread[config.getThreadCount()];
for(int i=0;i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy