Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send logs to kafka on start conversation (telemetry event) #11

Open
wants to merge 8 commits into
base: release-4.1.0
Choose a base branch
from
9 changes: 7 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -75,7 +81,7 @@
<artifactId>jaxb-impl</artifactId>
<version>2.2.11</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand All @@ -98,7 +104,6 @@
<version>1.0</version>
<scope>compile</scope>
</dependency>

</dependencies>

<build>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/uci/inbound/Inbound.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.springframework.data.cassandra.repository.config.EnableReactiveCassandraRepositories;
import org.springframework.kafka.annotation.EnableKafka;

import com.uci.dao.service.HealthService;
import com.uci.utils.kafka.KafkaLogConfig;

@EnableKafka
@EnableReactiveCassandraRepositories("com.uci.dao")
Expand All @@ -24,7 +24,7 @@
@SpringBootApplication
@ComponentScan(basePackages = {"com.uci.inbound", "com.uci.adapter", "com.uci.utils"})
public class Inbound {
public static void main(String[] args) {
public static void main(String[] args) throws InterruptedException {
SpringApplication.run(Inbound.class, args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
import com.uci.utils.BotService;
import com.uci.dao.service.HealthService;
import com.uci.utils.kafka.KafkaConfig;
import com.uci.utils.telemetry.LogTelemetryBuilder;
import com.uci.utils.telemetry.LogTelemetryMessage;
import com.uci.utils.telemetry.TelemetryLogger;

import lombok.extern.slf4j.Slf4j;
import reactor.core.publisher.Flux;
Expand All @@ -18,6 +21,9 @@
import java.io.IOException;
import java.util.Map;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.actuate.cassandra.CassandraHealthIndicator;
Expand All @@ -32,15 +38,9 @@
@RestController
@RequestMapping(value = "/service")
public class ServiceStatusController {
@Autowired
private HealthService healthService;

@RequestMapping(value = "/health", method = RequestMethod.GET, produces = { "application/json", "text/json" })
public ResponseEntity<JsonNode> statusCheck() throws JsonProcessingException {
ObjectMapper mapper = new ObjectMapper();
JsonNode json = mapper.readTree("{\"id\":\"api.content.service.health\",\"ver\":\"3.0\",\"ts\":null,\"params\":{\"resmsgid\":null,\"msgid\":null,\"err\":null,\"status\":\"successful\",\"errmsg\":null},\"responseCode\":\"OK\",\"result\":{\"healthy\":true}}");
return ResponseEntity.ok(json);
}
@Autowired
private HealthService healthService;

@RequestMapping(value = "/health/cassandra", method = RequestMethod.GET, produces = { "application/json", "text/json" })
public ResponseEntity<JsonNode> cassandraStatusCheck() throws IOException, JsonProcessingException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import com.uci.utils.kafka.SimpleProducer;
import lombok.extern.slf4j.Slf4j;
import com.uci.utils.BotService;
import com.uci.utils.CampaignService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
Expand Down Expand Up @@ -42,6 +44,9 @@ public class NetcoreWhatsappConverter {

@Autowired
public BotService botService;

@Autowired
public CampaignService campaignService;

@RequestMapping(value = "/whatsApp", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
public void netcoreWhatsApp(@RequestBody NetcoreMessageFormat message) throws JsonProcessingException, JAXBException {
Expand All @@ -60,6 +65,7 @@ public void netcoreWhatsApp(@RequestBody NetcoreMessageFormat message) throws Js
.topicSuccess(inboundProcessed)
.kafkaProducer(kafkaProducer)
.botService(botService)
.campaignService(campaignService)
.build()
.process();
}
Expand Down
Loading