Commit 48768bf7 authored by abdullh.alsoleman's avatar abdullh.alsoleman

final_project

parent 5728ee2d
......@@ -32,6 +32,24 @@
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-observation</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-tracing-bridge-brave</artifactId>
</dependency>
<dependency>
<groupId>io.zipkin.reporter2</groupId>
<artifactId>zipkin-reporter-brave</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
......
package resources;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/")
public class FallbackMethod {
@RequestMapping("competitions-fallback")
public String getCatalogFallback(){
//it can be an empty list or last cash result
return "Competition Service is temporary unavailable, Please Try Again Later";
}
@RequestMapping("Seasons-fallback")
public String getMovieFallback(){
//it can be an empty list or last cash result
return "Season Service is temporary unavailable, Please Try Again Later";
}
}
......@@ -11,10 +11,23 @@ spring:
uri: lb://history-Of-competition-service
predicates:
- Path=/competitions/**
filters:
- name: CircuitBreaker
args:
name: competitionCircuitBreaker
fallbackUri: forward:/competitions-fallback
- id: season-service
uri: lb://season-service
predicates:
- Path=/Seasons/**
filters:
- name: CircuitBreaker
args:
name: seasonCircuitBreaker
fallbackUri: forward:/Seasons-fallback
zipkin:
baseurl: http://localhost:9411
eureka:
client:
register-with-eureka: true
......@@ -23,4 +36,48 @@ eureka:
default-zone: http://localhost:8761/eureka/
# instance:
# hostname: localhost
# preferIpAddress: true
\ No newline at end of file
# preferIpAddress: true
management:
health:
circuitbreakers:
enabled: true
endpoints:
web:
exposure:
include: health,prometheus
endpoint:
health:
show-details: always
tracing:
sampling:
probability: 1.0
resilience4j:
circuitbreaker:
instances:
seasonCircuitBreaker:
registerHealthIndicator: true
eventConsumerBufferSize: 10
failureRateThreshold: 50
minimumNumberOfCalls: 5
automaticTransitionFromOpenToHalfOpenEnabled: true
waitDurationInOpenState: 10s
permittedNumberOfCallsInHalfOpenState: 3
slidingWindowSize: 10
slidingWindowType: COUNT_BASED
competitionCircuitBreaker:
registerHealthIndicator: true
eventConsumerBufferSize: 10
failureRateThreshold: 50
minimumNumberOfCalls: 5
automaticTransitionFromOpenToHalfOpenEnabled: true
waitDurationInOpenState: 10s
permittedNumberOfCallsInHalfOpenState: 3
slidingWindowSize: 10
slidingWindowType: COUNT_BASED
## traceID and spanId are predefined MDC keys - we want the logs to include them
logging:
pattern:
level: ${spring.application.name:},%X{traceId:-},%X{spanId:-}
......@@ -37,12 +37,37 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>7.2</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-tracing-bridge-brave</artifactId>
</dependency>
<dependency>
<groupId>io.zipkin.reporter2</groupId>
<artifactId>zipkin-reporter-brave</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
......
......@@ -2807,3 +2807,37 @@ com.netflix.discovery.shared.transport.TransportException: Cannot execute reques
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at org.springframework.boot.SpringApplicationShutdownHook.run(SpringApplicationShutdownHook.java:114)
at java.base/java.lang.Thread.run(Thread.java:833)
2024-04-28 13:43:13.098 [SpringApplicationShutdownHook] ERROR c.netflix.discovery.DiscoveryClient - DiscoveryClient_HISTORY-OF-COMPETITION-SERVICE/DESKTOP-RE2N10K:history-Of-competition-service:8080 - de-registration failedCannot execute request on any known server
com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:112)
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.cancel(EurekaHttpClientDecorator.java:71)
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$2.execute(EurekaHttpClientDecorator.java:74)
at com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77)
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.cancel(EurekaHttpClientDecorator.java:71)
at com.netflix.discovery.DiscoveryClient.unregister(DiscoveryClient.java:916)
at com.netflix.discovery.DiscoveryClient.shutdown(DiscoveryClient.java:892)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMethod.invoke(InitDestroyAnnotationBeanPostProcessor.java:457)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeDestroyMethods(InitDestroyAnnotationBeanPostProcessor.java:415)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeDestruction(InitDestroyAnnotationBeanPostProcessor.java:239)
at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:202)
at org.springframework.beans.factory.support.DisposableBeanAdapter.run(DisposableBeanAdapter.java:195)
at org.springframework.cloud.context.scope.GenericScope$BeanLifecycleWrapper.destroy(GenericScope.java:389)
at org.springframework.cloud.context.scope.GenericScope.destroy(GenericScope.java:136)
at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:211)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:587)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:559)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:1202)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:520)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:1195)
at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1186)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1147)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.doClose(ServletWebServerApplicationContext.java:174)
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1093)
at org.springframework.boot.SpringApplicationShutdownHook.closeAndWait(SpringApplicationShutdownHook.java:145)
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at org.springframework.boot.SpringApplicationShutdownHook.run(SpringApplicationShutdownHook.java:114)
at java.base/java.lang.Thread.run(Thread.java:833)
package Service.History_Of_Competition_Service;
import configuration.MQConfig;
import models.Competition;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -7,13 +8,26 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import configuration.MQConfig;
import java.util.ArrayList;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
@RestController
@Component
@Slf4j
@RequestMapping("/competitions")
public class CompetitionController {
private static final Logger LOGGER = LoggerFactory.getLogger(CompetitionController.class);
@Autowired
private RabbitTemplate rabbitTemplate;
@Autowired
RestTemplate restTemplate;
List<Competition> competitions = new ArrayList<>();
......@@ -28,4 +42,15 @@ public class CompetitionController {
Competition result= restTemplate.getForObject("http://season-service/Seasons/GetSeasonsStanding/"+"English_Premier_League",Competition.class);
return result;
}
@RequestMapping("/MQGetStanding/{CompetitionId}")
public String getHistoryEventOfCompetitionMQ(@PathVariable("CompetitionId") String CompetitionId){
rabbitTemplate.convertAndSend(MQConfig.EXCHANGE,MQConfig.SEA_REQ_ROUTING_KEY,CompetitionId);
LOGGER.info(String.format("Queued: Movie with id %s",CompetitionId));
return "Your request queued in RabbitMQ ...";
}
@RabbitListener(queues = MQConfig.MovieInfoRespQueue)
public void respCompetition(Competition competition){
log.info(String.format("Received Competition: %s, %s, %s, %s",competition.getId(),competition.getCountryName(),competition.getName(),competition.getSeasonList()));
}
}
......@@ -10,11 +10,7 @@ import org.springframework.web.client.RestTemplate;
@SpringBootApplication
@EnableDiscoveryClient
public class HistoryOfCompetitionServiceApplication {
@Bean
@LoadBalanced
public RestTemplate getRestTemplate(){
return new RestTemplate();
}
public static void main(String[] args) {
SpringApplication.run(HistoryOfCompetitionServiceApplication.class, args);
}
......
package configuration;
import org.springframework.amqp.core.*;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class MQConfig {
public static final String EXCHANGE = "req_exchange";
public static final String MovieInfoReqQueue = "seasonReq_queue";
public static final String MovieInfoRespQueue = "seasonResp_queue";
public static final String SEA_REQ_ROUTING_KEY = "SEA_REQ_RK";
@Bean
public Queue MovieInfoReqQueue() {
return new Queue(MovieInfoReqQueue);
}
@Bean
public TopicExchange topicExchange() {
return new TopicExchange(EXCHANGE);
}
@Bean
public Binding reqBinding() {
return BindingBuilder.bind(MovieInfoReqQueue()).to(topicExchange()).with(SEA_REQ_ROUTING_KEY);
}
@Bean
public MessageConverter messageConverter() {
return new Jackson2JsonMessageConverter();
}
@Bean
public AmqpTemplate amqpTemplate(ConnectionFactory connectionFactory) {
RabbitTemplate template = new RabbitTemplate(connectionFactory);
template.setMessageConverter(messageConverter());
return template;
}
}
......@@ -2,4 +2,12 @@ spring.application.name=history-Of-competition-service
server.port=8080
eureka.client.serviceUrl.defaultZone= ${EUREKA_URL:http://192.168.104.32:8761/eureka/}
# Set the metadata for the instance
eureka.instance.metadataMap.zone=zone2
\ No newline at end of file
eureka.instance.metadataMap.zone=zone2
spring.rabbitmq.addresses= localhost:5672
#Zipkin
spring.zipkin.baseurl= localhost:9411
# All traces should be sent to latency analysis tool, default sampling probability is 10%
management.tracing.sampling.probability=1.0
## traceID and spanId are predefined MDC keys - we want the logs to include them
logging.pattern.level=%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}]
\ No newline at end of file
......@@ -37,12 +37,41 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>7.2</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-observation</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-tracing-bridge-brave</artifactId>
</dependency>
<dependency>
<groupId>io.zipkin.reporter2</groupId>
<artifactId>zipkin-reporter-brave</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
......
This diff is collapsed.
package Service.Season_service;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import configuration.MQConfig;
import models.Competition;
import models.Event;
import models.Match_Event;
import models.Season;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -18,8 +26,12 @@ import java.util.ArrayList;
import java.util.List;
@RestController
@Slf4j
@RequestMapping("/Seasons")
public class SeasonController {
@Autowired
private RabbitTemplate rabbitTemplate;
@Autowired
RestTemplate restTemplate;
List<Season> seasons = new ArrayList<>() {{
......@@ -35,41 +47,89 @@ public class SeasonController {
List<Season> seasonResult = new ArrayList<>();
for (Season s : seasons) {
Season season = new Season(s.getId(), s.getStartYear(), s.getFinishYear());
// Event resultPart1 = restTemplate.getForObject("https://www.thesportsdb.com/api/v1/json/3/searchfilename.php?e=" + competitionName + "_" + s.getStartYear(), Event.class);
// Event resultPart2 = restTemplate.getForObject("https://www.thesportsdb.com/api/v1/json/3/searchfilename.php?e=" + competitionName + "_" + s.getFinishYear(), Event.class);
// season.getMatch_events().addAll(resultPart1.getMatch_events());
// season.getMatch_events().addAll(resultPart2.getMatch_events());
String result = restTemplate.getForObject("https://www.thesportsdb.com/api/v1/json/3/searchfilename.php?e=" + competitionName + "_" + s.getStartYear(), String.class);
ObjectMapper objectMapper = new ObjectMapper();
// Parse the JSON array
JsonNode jsonNode = objectMapper.readTree(result);
// Create a list to store the Match_Event objects
List<Match_Event> matchEvents = new ArrayList<>();
Event resultPart1 = restTemplate.getForObject("https://www.thesportsdb.com/api/v1/json/3/searchfilename.php?e=" + competitionName + "_" + s.getStartYear(), Event.class);
Event resultPart2 = restTemplate.getForObject("https://www.thesportsdb.com/api/v1/json/3/searchfilename.php?e=" + competitionName + "_" + s.getFinishYear(), Event.class);
season.getMatch_events().addAll(resultPart1.getEvent());
season.getMatch_events().addAll(resultPart2.getEvent());
// String result = restTemplate.getForObject("https://www.thesportsdb.com/api/v1/json/3/searchfilename.php?e=" + competitionName + "_" + s.getStartYear(), String.class);
// ObjectMapper objectMapper = new ObjectMapper();
// //Parse the JSON array
// JsonNode jsonNode = objectMapper.readTree(result);
// // Create a list to store the Match_Event objects
// List<Match_Event> matchEvents = new ArrayList<>();
// Iterate over the JSON array and create Match_Event objects
for (JsonNode node1 : jsonNode) {
for (JsonNode node : node1) {
Match_Event matchEvent = new Match_Event();
matchEvent.setIdEvent(node.get("idEvent").asText());
matchEvent.setStrEvent(node.get("strEvent").asText());
matchEvent.setDateEvent(node.get("dateEvent").asText());
matchEvent.setStrLeague(node.get("strLeague").asText());
matchEvent.setStrHomeTeam(node.get("strHomeTeam").asText());
matchEvent.setStrAwayTeam(node.get("strAwayTeam").asText());
matchEvent.setIntAwayScore(node.get("intHomeScore").asInt());
matchEvent.setIntAwayScore(node.get("intAwayScore").asInt());
matchEvents.add(matchEvent);
}
season.getMatch_events().addAll(matchEvents);
}
// for (JsonNode node1 : jsonNode) {
// for (JsonNode node : node1) {
// Match_Event matchEvent = new Match_Event();
// matchEvent.setIdEvent(node.get("idEvent").asText());
// matchEvent.setStrEvent(node.get("strEvent").asText());
// matchEvent.setDateEvent(node.get("dateEvent").asText());
// matchEvent.setStrLeague(node.get("strLeague").asText());
// matchEvent.setStrHomeTeam(node.get("strHomeTeam").asText());
// matchEvent.setStrAwayTeam(node.get("strAwayTeam").asText());
// matchEvent.setIntAwayScore(node.get("intHomeScore").asInt());
// matchEvent.setIntAwayScore(node.get("intAwayScore").asInt());
// matchEvents.add(matchEvent);
seasonResult.add(season);
}
// season.getMatch_events().addAll(matchEvents);
//}
//seasonResult.add(season);
//}
Competition response = new Competition();
response.setSeasonList(seasonResult);
response.setName(competitionName);
return response;
// seasons.add(season);
}
//competition.getSeasonList().addAll(seasons);
// return competition;
private static final Logger LOGGER = LoggerFactory.getLogger(SeasonController.class);
@RabbitListener(queues = MQConfig.SeasonInfoRespQueue)
public void respCompetition(String competitionName){
LOGGER.info(String.format("Received CompetitionName: %s", competitionName));
Competition competition = new Competition();
competition.setName(competitionName);
List<Season> seasonResult = new ArrayList<>();
for (Season s : seasons) {
Season season = new Season(s.getId(), s.getStartYear(), s.getFinishYear());
Event resultPart1 = restTemplate.getForObject("https://www.thesportsdb.com/api/v1/json/3/searchfilename.php?e=" + competitionName + "_" + s.getStartYear(), Event.class);
Event resultPart2 = restTemplate.getForObject("https://www.thesportsdb.com/api/v1/json/3/searchfilename.php?e=" + competitionName + "_" + s.getFinishYear(), Event.class);
season.getMatch_events().addAll(resultPart1.getEvent());
season.getMatch_events().addAll(resultPart2.getEvent());
// String result = restTemplate.getForObject("https://www.thesportsdb.com/api/v1/json/3/searchfilename.php?e=" + competitionName + "_" + s.getStartYear(), String.class);
// ObjectMapper objectMapper = new ObjectMapper();
// //Parse the JSON array
// JsonNode jsonNode = objectMapper.readTree(result);
// // Create a list to store the Match_Event objects
// List<Match_Event> matchEvents = new ArrayList<>();
// Iterate over the JSON array and create Match_Event objects
// for (JsonNode node1 : jsonNode) {
// for (JsonNode node : node1) {
// Match_Event matchEvent = new Match_Event();
// matchEvent.setIdEvent(node.get("idEvent").asText());
// matchEvent.setStrEvent(node.get("strEvent").asText());
// matchEvent.setDateEvent(node.get("dateEvent").asText());
// matchEvent.setStrLeague(node.get("strLeague").asText());
// matchEvent.setStrHomeTeam(node.get("strHomeTeam").asText());
// matchEvent.setStrAwayTeam(node.get("strAwayTeam").asText());
// matchEvent.setIntAwayScore(node.get("intHomeScore").asInt());
// matchEvent.setIntAwayScore(node.get("intAwayScore").asInt());
// matchEvents.add(matchEvent);
seasonResult.add(season);
}
// season.getMatch_events().addAll(matchEvents);
//}
//seasonResult.add(season);
//}
Competition response = new Competition();
response.setSeasonList(seasonResult);
response.setName(competitionName);
rabbitTemplate.convertAndSend(MQConfig.EXCHANGE,MQConfig.SEA_RES_ROUTING_KEY,response);
log.info(String.format("Queued: Movie with id %s",response.getId()));
}
}
......@@ -3,7 +3,11 @@ package Service.Season_service;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import configuration.MQConfig;
@SpringBootApplication
@EnableDiscoveryClient
public class SeasonServiceApplication {
......
package configuration;
import org.springframework.amqp.core.*;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class MQConfig {
public static final String EXCHANGE = "req_exchange";
public static final String SeasonInfoReqQueue = "seasonReq_queue";
public static final String SeasonInfoRespQueue = "seasonResp_queue";
public static final String SEA_REQ_ROUTING_KEY = "SEA_REQ_RK";
public static final String SEA_RES_ROUTING_KEY = "SEA_RES_RK";
@Bean
public Queue SeasonInfoReqQueue() {
return new Queue(SeasonInfoReqQueue);
}
@Bean
public Queue SeasonInfoRespQueue() {
return new Queue(SeasonInfoRespQueue);
}
@Bean
public TopicExchange topicExchange() {
return new TopicExchange(EXCHANGE);
}
@Bean
public Binding reqBinding() {
return BindingBuilder.bind(SeasonInfoReqQueue()).to(topicExchange()).with(SEA_REQ_ROUTING_KEY);
}
@Bean
public Binding respBinding(){
return BindingBuilder.bind(SeasonInfoRespQueue()).to(topicExchange()).with(SEA_RES_ROUTING_KEY);
}
@Bean
public MessageConverter messageConverter() {
return new Jackson2JsonMessageConverter();
}
@Bean
public AmqpTemplate amqpTemplate(ConnectionFactory connectionFactory) {
RabbitTemplate template = new RabbitTemplate(connectionFactory);
template.setMessageConverter(messageConverter());
return template;
}
}
......@@ -4,14 +4,15 @@ import java.util.ArrayList;
import java.util.List;
public class Event {
private List<Match_Event> match_events = new ArrayList<>();
private List<Match_Event> event = new ArrayList<>();
public void setMatch_events(List<Match_Event> match_events) {
this.match_events = match_events;
public void setEvent(List<Match_Event> event) {
this.event = event;
}
public List<Match_Event> getMatch_events() {
return match_events;
public List<Match_Event> getEvent() {
return event;
}
public Event() {
......
......@@ -7,40 +7,29 @@ public class Match_Event {
}
// Unique identifier for the event
@JsonProperty("idEvent")
private String idEvent;
// Name of the event
@JsonProperty("strEvent")
private String strEvent;
// Date of the event
@JsonProperty("dateEvent")
private String dateEvent;
// League associated with the event
@JsonProperty("strLeague")
private String strLeague;
// Name of the home team
@JsonProperty("strHomeTeam")
private String strHomeTeam;
// Name of the away team
@JsonProperty("strAwayTeam")
private String strAwayTeam;
// Home team's score
@JsonProperty("intHomeScore")
private int intHomeScore;
// Away team's score
@JsonProperty("intAwayScore")
private int intAwayScore;
// Define other properties as needed
// Constructor
// Getters and setters
public String getIdEvent() {
......
......@@ -2,4 +2,13 @@ spring.application.name=season-service
server.port=8081
eureka.client.serviceUrl.defaultZone= ${EUREKA_URL:http://192.168.104.32:8761/eureka/}
# Set the metadata for the instance
eureka.instance.metadataMap.zone=zone2
\ No newline at end of file
eureka.instance.metadataMap.zone=zone2
eureka.instance.preferIpAddress= true
spring.rabbitmq.addresses= localhost:5672
#Zipkin
spring.zipkin.baseurl= localhost:9411
# All traces should be sent to latency analysis tool, default sampling probability is 10%
management.tracing.sampling.probability=1.0
## traceID and spanId are predefined MDC keys - we want the logs to include them
logging.pattern.level=%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}]
\ No newline at end of file
version: '3'
services:
prometheus:
image: prom/prometheus
container_name: prometheus
volumes:
- ./docker/prometheus-desktop.yml:/etc/prometheus/prometheus.yml
ports:
- "9091:9090"
networks:
- net
grafana:
image: grafana/grafana
container_name: grafana
env_file:
- ./docker/grafana.env
ports:
- "3000:3000"
networks:
- net
rabbitmq:
image: rabbitmq:3-management
container_name: rabbitmq
ports:
- "15672:15672"
- "5672:5672"
networks:
- net
networks:
net:
\ No newline at end of file
version: "3"
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.3.3
container_name: elasticsearch
environment:
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- "discovery.type=single-node"
- xpack.security.enabled=false
ports:
- "9200:9200"
volumes:
- elasticsearch_data:/usr/share/elasticsearch/data
networks:
- elastic
kibana:
image: docker.elastic.co/kibana/kibana:8.3.3
container_name: kibana
ports:
- "5601:5601"
environment:
ELASTICSEARCH_URL: http://elasticsearch:9200
ELASTICSEARCH_HOSTS: '["http://elasticsearch:9200"]'
depends_on:
- elasticsearch
networks:
- elastic
logstash:
image: docker.elastic.co/logstash/logstash:8.3.3
container_name: logstash
volumes:
- ./docker/logstash/config/logstash.yml:/usr/share/logstash/config/logstash.yml:ro
- ./docker/logstash/pipeline:/usr/share/logstash/pipeline:ro
ports:
- "5044:5044"
- "5000:5000/tcp"
- "5000:5000/udp"
- "9600:9600"
environment:
LS_JAVA_OPTS: "-Xmx256m -Xms256m"
networks:
- elastic
depends_on:
- elasticsearch
zipkin:
image: openzipkin/zipkin
container_name: zipkin
ports:
- "9411:9411"
networks:
- elastic
networks:
elastic:
driver: bridge
volumes:
elasticsearch_data:
driver: local
\ No newline at end of file
This diff is collapsed.
# [server]
# GF_SERVER_DOMAIN=localhost
# GF_SERVER_HTTP_PORT=3000
# GF_SERVER_PROTOCOL=http
\ No newline at end of file
http.host: "0.0.0.0"
path.config: /usr/share/logstash/pipeline
xpack.monitoring.elasticsearch.hosts: [ "elasticsearch:9200" ]
\ No newline at end of file
input {
tcp{
port => 5000
codec => json
}
}
output {
elasticsearch {
hosts => "elasticsearch:9200"
index => "springboot-%{app}"
}
}
\ No newline at end of file
global:
scrape_interval: 15s # By default, scrape targets every 15 seconds.
# Attach these labels to any time series or alerts when communicating with
# external systems (federation, remote storage, Alertmanager).
external_labels:
monitor: 'resilience4j-monitor'
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: 'prometheus'
# Override the global default and scrape targets from this job every 5 seconds.
scrape_interval: 5s
static_configs:
- targets: ['localhost:9090']
- job_name: 'Movie-Catalog-Gateway'
# Override the global default and scrape targets from this job every 5 seconds.
scrape_interval: 5s
metrics_path: /actuator/prometheus
static_configs:
# Use the service name (see docker-compose-desktop.yml) instead of localhost
- targets: ['host.docker.internal:9090']
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