init
commit
2d2a9e8909
|
|
@ -0,0 +1,33 @@
|
|||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.6.3</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>pl.adaptiveapps</groupId>
|
||||
<artifactId>service-external-server</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>service-external-server</name>
|
||||
<description>External Server For Service App</description>
|
||||
<properties>
|
||||
<java.version>11</java.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.kafka</groupId>
|
||||
<artifactId>spring-kafka</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>pl.adaptiveapps</groupId>
|
||||
<artifactId>service-kafka-model</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package pl.adaptiveapps.serviceexternalserver;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class ServiceExternalServerApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ServiceExternalServerApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package pl.adaptiveapps.serviceexternalserver.controller;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import pl.adaptiveapps.service.kafkamodel.msg.external.FormSavedMsg;
|
||||
import pl.adaptiveapps.service.kafkamodel.msg.external.WorktimeSavedMsg;
|
||||
import pl.adaptiveapps.serviceexternalserver.kafka.FormSavedProducer;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@RestController("/form")
|
||||
public class FormSavedController {
|
||||
|
||||
private final FormSavedProducer formSavedProducer;
|
||||
|
||||
@PostMapping("/")
|
||||
public void postForm(@RequestBody FormSavedMsg formSavedMsg){
|
||||
formSavedProducer.sendMessage(formSavedMsg);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package pl.adaptiveapps.serviceexternalserver.controller;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import pl.adaptiveapps.service.kafkamodel.msg.external.NoteSavedMsg;
|
||||
import pl.adaptiveapps.service.kafkamodel.msg.external.WorktimeSavedMsg;
|
||||
import pl.adaptiveapps.serviceexternalserver.kafka.NotesProducer;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@RestController("/note")
|
||||
public class NotesController {
|
||||
|
||||
private final NotesProducer notesProducer;
|
||||
|
||||
@PostMapping("/")
|
||||
public void postNote(@RequestBody NoteSavedMsg noteSavedMsg){
|
||||
notesProducer.sendMessage(noteSavedMsg);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package pl.adaptiveapps.serviceexternalserver.controller;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import pl.adaptiveapps.service.kafkamodel.msg.external.PhotoSavedMsg;
|
||||
import pl.adaptiveapps.service.kafkamodel.msg.external.WorktimeSavedMsg;
|
||||
import pl.adaptiveapps.serviceexternalserver.kafka.PhotosProducer;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@RestController("/photo")
|
||||
public class PhotosController {
|
||||
|
||||
private final PhotosProducer photosProducer;
|
||||
|
||||
@PostMapping("/")
|
||||
public void postPhoto(@RequestBody PhotoSavedMsg photoSavedMsg){
|
||||
photosProducer.sendMessage(photoSavedMsg);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package pl.adaptiveapps.serviceexternalserver.controller;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import pl.adaptiveapps.service.kafkamodel.msg.external.RecipienceLogSavedMsg;
|
||||
import pl.adaptiveapps.service.kafkamodel.msg.external.WorktimeSavedMsg;
|
||||
import pl.adaptiveapps.serviceexternalserver.kafka.RecipienceProducer;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@RestController("/recipience")
|
||||
public class RecipienceController {
|
||||
|
||||
private final RecipienceProducer recipienceProducer;
|
||||
|
||||
@PostMapping("/")
|
||||
public void postRecipience(@RequestBody RecipienceLogSavedMsg recipienceLogSavedMsg){
|
||||
recipienceProducer.sendMessage(recipienceLogSavedMsg);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package pl.adaptiveapps.serviceexternalserver.controller;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import pl.adaptiveapps.service.kafkamodel.msg.external.ServicemanChangedMsg;
|
||||
import pl.adaptiveapps.service.kafkamodel.msg.external.WorktimeSavedMsg;
|
||||
import pl.adaptiveapps.serviceexternalserver.kafka.ServicemanProducer;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@RestController("/serviceman")
|
||||
public class ServicemanController {
|
||||
|
||||
private final ServicemanProducer servicemanProducer;
|
||||
|
||||
@PostMapping("/")
|
||||
public void postServiceman(@RequestBody ServicemanChangedMsg servicemanChangedMsg){
|
||||
servicemanProducer.sendMessage(servicemanChangedMsg);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package pl.adaptiveapps.serviceexternalserver.controller;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import pl.adaptiveapps.service.kafkamodel.msg.external.StatusChangedMsg;
|
||||
import pl.adaptiveapps.service.kafkamodel.msg.external.WorktimeSavedMsg;
|
||||
import pl.adaptiveapps.serviceexternalserver.kafka.StatusProducer;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@RestController("/status")
|
||||
public class StatusController {
|
||||
|
||||
private final StatusProducer statusProducer;
|
||||
|
||||
@PostMapping("/")
|
||||
public void postStatus(@RequestBody StatusChangedMsg statusChangedMsg){
|
||||
statusProducer.sendMessage(statusChangedMsg);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package pl.adaptiveapps.serviceexternalserver.controller;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import pl.adaptiveapps.service.kafkamodel.msg.external.WarehouseItemReleaseMsg;
|
||||
import pl.adaptiveapps.service.kafkamodel.msg.external.WorktimeSavedMsg;
|
||||
import pl.adaptiveapps.serviceexternalserver.kafka.WarehouseProducer;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@RestController("/warehouse")
|
||||
public class WarehouseController {
|
||||
|
||||
private final WarehouseProducer warehouseProducer;
|
||||
|
||||
@PostMapping("/")
|
||||
public void postWarehouse(@RequestBody WarehouseItemReleaseMsg warehouseItemReleaseMsg){
|
||||
warehouseProducer.sendMessage(warehouseItemReleaseMsg);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package pl.adaptiveapps.serviceexternalserver.controller;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import pl.adaptiveapps.service.kafkamodel.msg.external.WorktimeSavedMsg;
|
||||
import pl.adaptiveapps.serviceexternalserver.kafka.WorktimeProducer;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@RestController("/worktime")
|
||||
public class WorktimeController {
|
||||
|
||||
private final WorktimeProducer worktimeProducer;
|
||||
|
||||
@PostMapping("/")
|
||||
public void postWorktime(@RequestBody WorktimeSavedMsg worktimeSavedMsg){
|
||||
worktimeProducer.sendMessage(worktimeSavedMsg);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
package pl.adaptiveapps.serviceexternalserver.kafka;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.kafka.core.KafkaTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import pl.adaptiveapps.service.kafkamodel.common.KafkaTopic;
|
||||
import pl.adaptiveapps.service.kafkamodel.msg.external.FormSavedMsg;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class FormSavedProducer {
|
||||
private static final Logger logger = LoggerFactory.getLogger(FormSavedProducer.class);
|
||||
|
||||
private final KafkaTemplate<String, String> kafkaTemplate;
|
||||
|
||||
public void sendMessage(FormSavedMsg formSavedMsg) {
|
||||
try {
|
||||
String message = new Gson().toJson(formSavedMsg);
|
||||
var res = this.kafkaTemplate.send(KafkaTopic.FORM_SAVED, message).get();
|
||||
logger.info(String.format("#### -> formSavedMsg message sent -> %s", res.getRecordMetadata().topic()));
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
package pl.adaptiveapps.serviceexternalserver.kafka;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.kafka.core.KafkaTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import pl.adaptiveapps.service.kafkamodel.common.KafkaTopic;
|
||||
import pl.adaptiveapps.service.kafkamodel.msg.external.NoteSavedMsg;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class NotesProducer {
|
||||
private static final Logger logger = LoggerFactory.getLogger(NotesProducer.class);
|
||||
|
||||
private final KafkaTemplate<String, String> kafkaTemplate;
|
||||
|
||||
public void sendMessage(NoteSavedMsg noteSavedMsg) {
|
||||
try {
|
||||
String message = new Gson().toJson(noteSavedMsg);
|
||||
var res = this.kafkaTemplate.send(KafkaTopic.NOTE_SAVED, message).get();
|
||||
logger.info(String.format("#### -> noteSavedMsg message sent -> %s", res.getRecordMetadata().topic()));
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
package pl.adaptiveapps.serviceexternalserver.kafka;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.kafka.core.KafkaTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import pl.adaptiveapps.service.kafkamodel.common.KafkaTopic;
|
||||
import pl.adaptiveapps.service.kafkamodel.msg.external.PhotoSavedMsg;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class PhotosProducer {
|
||||
private static final Logger logger = LoggerFactory.getLogger(PhotosProducer.class);
|
||||
|
||||
private final KafkaTemplate<String, String> kafkaTemplate;
|
||||
|
||||
public void sendMessage(PhotoSavedMsg photoSavedMsg) {
|
||||
try {
|
||||
String message = new Gson().toJson(photoSavedMsg);
|
||||
var res = this.kafkaTemplate.send(KafkaTopic.PHOTO_SAVED, message).get();
|
||||
logger.info(String.format("#### -> photoSavedMsg message sent -> %s", res.getRecordMetadata().topic()));
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
package pl.adaptiveapps.serviceexternalserver.kafka;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.kafka.core.KafkaTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import pl.adaptiveapps.service.kafkamodel.common.KafkaTopic;
|
||||
import pl.adaptiveapps.service.kafkamodel.msg.external.RecipienceLogSavedMsg;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class RecipienceProducer {
|
||||
private static final Logger logger = LoggerFactory.getLogger(RecipienceProducer.class);
|
||||
|
||||
private final KafkaTemplate<String, String> kafkaTemplate;
|
||||
|
||||
public void sendMessage(RecipienceLogSavedMsg recipienceLogSavedMsg) {
|
||||
try {
|
||||
String message = new Gson().toJson(recipienceLogSavedMsg);
|
||||
var res = this.kafkaTemplate.send(KafkaTopic.RECIPIENCE, message).get();
|
||||
logger.info(String.format("#### -> recipience message sent -> %s", res.getRecordMetadata().topic()));
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
package pl.adaptiveapps.serviceexternalserver.kafka;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.kafka.core.KafkaTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import pl.adaptiveapps.service.kafkamodel.common.KafkaTopic;
|
||||
import pl.adaptiveapps.service.kafkamodel.msg.external.ServicemanChangedMsg;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ServicemanProducer {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ServicemanProducer.class);
|
||||
|
||||
private final KafkaTemplate<String, String> kafkaTemplate;
|
||||
|
||||
public void sendMessage(ServicemanChangedMsg servicemanChangedMsg) {
|
||||
try {
|
||||
String message = new Gson().toJson(servicemanChangedMsg);
|
||||
var res = this.kafkaTemplate.send(KafkaTopic.SERVICEMAN_CHANGE, message).get();
|
||||
logger.info(String.format("#### -> serviceman message sent -> %s", res.getRecordMetadata().topic()));
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
package pl.adaptiveapps.serviceexternalserver.kafka;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.kafka.core.KafkaTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import pl.adaptiveapps.service.kafkamodel.common.KafkaTopic;
|
||||
import pl.adaptiveapps.service.kafkamodel.msg.external.StatusChangedMsg;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class StatusProducer {
|
||||
private static final Logger logger = LoggerFactory.getLogger(StatusProducer.class);
|
||||
|
||||
private final KafkaTemplate<String, String> kafkaTemplate;
|
||||
|
||||
public void sendMessage(StatusChangedMsg statusChangedMsg) {
|
||||
try {
|
||||
String message = new Gson().toJson(statusChangedMsg);
|
||||
var res = this.kafkaTemplate.send(KafkaTopic.STATUS_CHANGE, message).get();
|
||||
logger.info(String.format("#### -> status message sent -> %s", res.getRecordMetadata().topic()));
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
package pl.adaptiveapps.serviceexternalserver.kafka;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.kafka.core.KafkaTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import pl.adaptiveapps.service.kafkamodel.common.KafkaTopic;
|
||||
import pl.adaptiveapps.service.kafkamodel.msg.external.WarehouseItemReleaseMsg;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class WarehouseProducer {
|
||||
private static final Logger logger = LoggerFactory.getLogger(WarehouseProducer.class);
|
||||
|
||||
private final KafkaTemplate<String, String> kafkaTemplate;
|
||||
|
||||
public void sendMessage(WarehouseItemReleaseMsg warehouseItemReleaseMsg) {
|
||||
try {
|
||||
String message = new Gson().toJson(warehouseItemReleaseMsg);
|
||||
var res = this.kafkaTemplate.send(KafkaTopic.WAREHOUSE_RELEASE, message).get();
|
||||
logger.info(String.format("#### -> warehosue message sent -> %s", res.getRecordMetadata().topic()));
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package pl.adaptiveapps.serviceexternalserver.kafka;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.kafka.core.KafkaTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import pl.adaptiveapps.service.kafkamodel.common.KafkaTopic;
|
||||
import pl.adaptiveapps.service.kafkamodel.msg.external.ExternalNoteCommand;
|
||||
import pl.adaptiveapps.service.kafkamodel.msg.external.WorktimeSavedMsg;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class WorktimeProducer {
|
||||
private static final Logger logger = LoggerFactory.getLogger(WorktimeProducer.class);
|
||||
|
||||
private final KafkaTemplate<String, String> kafkaTemplate;
|
||||
|
||||
public void sendMessage(WorktimeSavedMsg worktimeSavedMsg) {
|
||||
try {
|
||||
String message = new Gson().toJson(worktimeSavedMsg);
|
||||
var res = this.kafkaTemplate.send(KafkaTopic.WORKTIME, message).get();
|
||||
logger.info(String.format("#### -> worktime message sent -> %s", res.getRecordMetadata().topic()));
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package pl.adaptiveapps.serviceexternalserver;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class ServiceExternalServerApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue