Commit 43153221 authored by Ramu Dosapati's avatar Ramu Dosapati

added admin server client for logs

parent 889971ec
This diff is collapsed.
......@@ -17,6 +17,9 @@ configurations {
repositories {
mavenCentral()
}
ext {
set('springBootAdminVersion', "2.7.4")
}
dependencies {
implementation group: 'org.modelmapper', name: 'modelmapper', version: '3.1.0'
......@@ -31,8 +34,15 @@ dependencies {
testImplementation 'org.springframework.kafka:spring-kafka-test'
implementation group: 'io.springfox', name: 'springfox-boot-starter', version: '3.0.0'
compileOnly group: 'org.json', name: 'json', version: '20180813'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'de.codecentric:spring-boot-admin-starter-client'
}
dependencyManagement {
imports {
mavenBom "de.codecentric:spring-boot-admin-dependencies:${springBootAdminVersion}"
}
}
tasks.named('test') {
useJUnitPlatform()
}
#spring.active.profiles=prod
#Springboot Application
spring.application.name=spring-boot-management
server.port=8789
spring.mvc.pathmatch.matching-strategy = ANT_PATH_MATCHER
client.host=http://localhost:8789
#Mongodb
spring.data.mongodb.database=pricingdb
spring.data.mongodb.host=localhost
spring.data.mongodb.port=27017
#actuator
management.endpoints.web.exposure.include=*
management.endpoint.health.show-details=always
management.endpoint.loggers.enabled=true
management.server.servlet.context-path=/actuator
#Admin server
spring.boot.admin.client.url=http://localhost:8081
spring.boot.admin.client.instance.prefer-ip=true
#Logfile
logging.file.name=product-service.log
logging.file.max-history=20
logging.file..max-size=20MB
spring:
data:
mongodb:
database: pricingdb
host: localhost
port: 27017
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
package com.safeway.pricing.safeway;
import com.safeway.pricing.safeway.client.SafewayClient;
/*import com.safeway.pricing.safeway.entity.PriceDetails;
import com.safeway.pricing.safeway.filereader.ExcelReader;
import com.safeway.pricing.safeway.kafka.SendKafkaMessage;*/
import lombok.extern.slf4j.Slf4j;
import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import reactor.core.publisher.Flux;
import java.io.FileInputStream;
@SpringBootApplication
public class SafewayPricingPodApplication {
......@@ -27,4 +20,8 @@ public class SafewayPricingPodApplication {
return new ModelMapper();
}
}
package com.safeway.pricing.safeway.controller;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/log")
@Slf4j
public class LoggingController {
@GetMapping
public String log() {
log.trace("This is a TRACE level message");
log.debug("This is a DEBUG level message");
log.info("This is an INFO level message");
log.warn("This is a WARN level message");
log.error("This is an ERROR level message");
return "See the log for details";
}
}
\ No newline at end of file
......@@ -52,6 +52,7 @@ public class PricingService {
storeDetailsMany=Sinks.many().replay().all();
}
public void getStoreDetails(String storeName) {
createSink();
List<StoreDetails> storeDetailsList=pricingServiceData.getStoreDetails();
List<StoreDetails> storeDetailsList1=storeDetailsList.stream().filter(storeDetails -> storeDetails.getStoreName().equalsIgnoreCase(storeName)).collect(Collectors.toList());
Flux.fromIterable(storeDetailsList1).subscribe(storeDetails -> storeDetailsMany.tryEmitNext(storeDetails));
......@@ -68,7 +69,13 @@ public class PricingService {
}
public Mono<StoreDetails> addStoreDetails(StoreDetails storeDetails){
return pricingServiceData.addStore(storeDetails).doOnNext(storeDetails1 -> storeDetailsMany.tryEmitNext(storeDetails1));
Mono<StoreDetails> storeDetailsMono;
if(storeDetailsMany==null){
storeDetailsMono = pricingServiceData.addStore(storeDetails);
}else
storeDetailsMono = pricingServiceData.addStore(storeDetails).doOnNext(storeDetails1 -> storeDetailsMany.tryEmitNext(storeDetails1));
return storeDetailsMono;
}
public Flux<ItemDetailsDTO> getItemDetails() {
return Flux.fromIterable(this.repository.findAll())
......
#spring.active.profiles=prod
#Springboot Application
spring.application.name=spring-boot-management
server.port=8789
spring.mvc.pathmatch.matching-strategy = ANT_PATH_MATCHER
client.host=http://localhost:8789
#Mongodb
spring.data.mongodb.database=pricingdb
spring.data.mongodb.host=localhost
spring.data.mongodb.port=27017
#actuator
management.endpoints.web.exposure.include=*
management.endpoint.health.show-details=always
management.endpoint.loggers.enabled=true
management.server.servlet.context-path=/actuator
#Admin server
spring.boot.admin.client.url=http://localhost:8081
spring.boot.admin.client.instance.prefer-ip=true
#Logfile
logging.file.name=product-service.log
logging.file.max-history=20
logging.file.max-size=20MB
spring:
data:
mongodb:
database: pricingdb
host: localhost
port: 27017
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment