This commit is contained in:
lxy
2020-08-18 14:21:54 +08:00
parent 1b54d52cf0
commit c8746b712e
2 changed files with 21 additions and 1 deletions

View File

@@ -30,7 +30,13 @@ public class KafakProducer<T extends Event> implements IProducer<T>, Service {
@Override
public void init(AnyValue config) {
try (FileInputStream fis = new FileInputStream(new File(APP_HOME, "conf/kafak.properties"));) {
File file = new File(APP_HOME, "conf/kafak.properties");
if (!file.exists()) {
logger.warning(String.format("------\n%s (系统找不到指定的文件。)\n未初始化kafak 生产者kafak发布消息不可用\n------", file.getPath()));
return;
}
try (FileInputStream fis = new FileInputStream(file)) {
Properties props = new Properties();
props.load(fis);
producer = new KafkaProducer(props);