一段时间后,由于该原因我的微服务应用程序停止运行,一旦启动我的微服务应用程序,是否有任何方法可以不依赖于kafka来启动我的服务?
请找到以下详细信息:
yml文件中的配置
kafka:
host: dit-grid-kafka.ebiz.verizon.com
port: 9092
logTopic: ONEGRID_MS_APPLICATIONS_LOGS_TOPIC
在源代码中:
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
Configuration config= ctx.getConfiguration();
//kafka host name and port number
Property kafkaHost = Property.createProperty(AppConstants.KAFKA_BOOTSTRAP_SERVER,
prop.getKafkaHost()+":"+prop.getKafkaPort());
Property[] properties = new Property[]{kafkaHost};
LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
//creating the pattern layout
Layout<? extends Serializable> layout = PatternLayout.newBuilder()
.withPattern("[%p] %m%n")
.build();
//creating the Kafka Appender and adding the layout
Appender appender = KafkaAppender.newBuilder()
.withName("org.apache.kafka")
.setProperties(properties)
.setSyncSend(false)
.setTopic(prop.getLogTopic())
.withLayout(layout)
.setConfiguration(config)
.build();
appender.start();