json 설정파일의 key를 camel case로 변경

main
semin.baek 10 months ago
parent b9547d6b21
commit 8698ef7914

@ -1,22 +1,22 @@
{
"sender": {
"host-id": "sam",
"hostId": "sam",
"timestamp": 1750643945523
},
"message-uuid": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6e",
"message-type": "SAVE_FILE",
"messageUuid": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6e",
"messageType": "SAVE_FILE",
"recipient": {
"host-id": "defree",
"drop-box-id": "receive-work-image-file"
"hostId": "defree",
"dropBoxId": "receive-work-image-file"
},
"data": [
{
"file-name": "v1.jpg",
"meta-data": {
"fileName": "v1.jpg",
"metaData": {
"FILE_ID": "F1V1JPG",
"ORIGINAL_FILE_NAME": "현장사진1.jpg"
},
"meta-drop-box-id": "save-work-image-file-info"
"metaDropBoxId": "save-work-image-file-info"
}
]
}

@ -1,13 +1,13 @@
{
"sender": {
"host-id": "sam",
"hostId": "sam",
"timestamp": 1740643945523
},
"message-uuid": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"message-type": "SAVE_DB_DATA",
"messageUuid": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"messageType": "SAVE_DB_DATA",
"recipient": {
"host-id": "defree",
"drop-box-id": "save-violation-history"
"hostId": "defree",
"dropBoxId": "save-violation-history"
},
"data": [
{

@ -1,112 +1,135 @@
{
"host-id": "first-agent",
"listen-port": 16801,
"known-agent-list": [
"myHostId": "first-agent",
"myListenPort": 16801,
"knownAgentList": [
{
"host-id": "second-agent",
"host-name": "mkami.foxsoft.kr",
"listen-port": 16801,
"drop-box-id-list": ["drop1", "drop2"]
"hostId": "second-agent",
"hostName": "mkami.foxsoft.kr",
"listenPort": 16801,
"dropBoxIdList": [
"drop1",
"drop2"
]
},
{
"host-id": "third-agent",
"host-name": "defree.co.kr",
"listen-port": 16801,
"drop-box-id-list": ["drop3", "drop4"]
"hostId": "third-agent",
"hostName": "defree.co.kr",
"listenPort": 16801,
"dropBoxIdList": [
"drop3",
"drop4"
]
}
],
"data-source-config": [
"dataSourceConfig": [
{
"data-source-id": "dfcms",
"dataSourceId": "dfcms",
"driverClassName": "org.postgresql.Driver",
"url": "jdbc:postgresql://bsm-lab.com:5432/defree?currentSchema=DFCMS",
"username": "defreeadmin",
"password": "qortpals1!"
},
{
"data-source-id": "mochastory",
"dataSourceId": "mochastory",
"driverClassName": "com.mysql.jdbc.Driver",
"url": "jdbc:mysql://bsm-lab.com:3306/MOCHASTORY?allowPublicKeyRetrieval=true",
"username": "MOCHASTORY",
"password": "MOCHASTORY"
}
],
"sqlMapperLocations": ["D:/projects/bsm-lab/dfx/dfxagent/src/docs/mapper-examples/**/*.xml"],
"drop-box": {
"received-message-storage-root": "D:/projects/bsm-lab/dfx/dfxagent/src/docs/messages/received",
"processed-message-storage-root": "D:/projects/bsm-lab/dfx/dfxagent/src/docs/messages/processed",
"failure-message-storage-root": "D:/projects/bsm-lab/dfx/dfxagent/src/docs/messages/failure",
"drop-box-list": [
"sqlMapperLocations": [
"D:/projects/bsm-lab/dfx/dfxagent/src/docs/mapper-examples/**/*.xml"
],
"dropBox": {
"receivedMessageStorageRoot": "D:/projects/bsm-lab/dfx/dfxagent/src/docs/messages/received",
"processedMessageStorageRoot": "D:/projects/bsm-lab/dfx/dfxagent/src/docs/messages/processed",
"failureMessageStorageRoot": "D:/projects/bsm-lab/dfx/dfxagent/src/docs/messages/failure",
"dropBoxList": [
{
"drop-box-id": "save-violation-history",
"task-type": "RECEIVE_DB_TO_DB_SAVE",
"data-source-id": "dfcms",
"sql-id": "dfcms.violation.insertViolationHistory"
"dropBoxId": "save-violation-history",
"taskType": "RECEIVE_DB_TO_DB_SAVE",
"dataSourceId": "dfcms",
"sqlId": "dfcms.violation.insertViolationHistory"
},
{
"drop-box-id": "receive-work-image-file",
"task-type": "RECEIVE_FILE",
"save-directory-root": "D:\\projects\\bsm-lab\\dfx\\run\\receive_file"
"dropBoxId": "receive-work-image-file",
"taskType": "RECEIVE_FILE",
"saveDirectoryRoot": "D:\\projects\\bsm-lab\\dfx\\run\\receive_file"
},
{
"drop-box-id": "save-work-image-file-info",
"task-type": "RECEIVE_DB_TO_DB_SAVE",
"data-source-id": "dfcms",
"sql-id": "dfcms.file.insertFileInfo"
"dropBoxId": "save-work-image-file-info",
"taskType": "RECEIVE_DB_TO_DB_SAVE",
"dataSourceId": "dfcms",
"sqlId": "dfcms.file.insertFileInfo"
}
]
},
"postman": [
{
"postman-id": "postman1",
"task-type": "DB_READ_THEN_SEND",
"postmanId": "postman1",
"taskType": "DB_READ_THEN_SEND",
"action": {
"type": "TRIGGER",
"command": "runSelectSomeThenSend",
"parameters-key-list": ["REG_DATE_FROM", "REG_DATE_TO"]
"parametersKeyList": [
"REG_DATE_FROM",
"REG_DATE_TO"
]
},
"message": {
"message-type": "TRANSFER_DB_TO_DB",
"data-source-id": "dfcms",
"sql-id": "dfcms.selectSome"
"messageType": "TRANSFER_DB_TO_DB",
"dataSourceId": "dfcms",
"sqlId": "dfcms.selectSome"
},
"recipient-host-id": "third-agent",
"recipient-drop-box-id": "drop3",
"routing-host-id-list": ["first-agent", "second-agent", "third-agent"]
"recipientHostId": "third-agent",
"recipientDropBoxId": "drop3",
"routingHostIdList": [
"first-agent",
"second-agent",
"third-agent"
]
},
{
"postman-id": "postman2",
"task-type": "DB_READ_THEN_SEND",
"postmanId": "postman2",
"taskType": "DB_READ_THEN_SEND",
"action": {
"type": "SCHEDULED",
"cron": "0 0 3 * * *"
},
"message": {
"message-type": "TRANSFER_DB_TO_DB",
"data-source-id": "dfcms",
"sql-id": "dfcms.selectSome"
"messageType": "TRANSFER_DB_TO_DB",
"dataSourceId": "dfcms",
"sqlId": "dfcms.selectSome"
},
"recipient-host-id": "third-agent",
"recipient-drop-box-id": "drop3",
"routing-host-id-list": ["first-agent", "second-agent", "third-agent"]
"recipientHostId": "third-agent",
"recipientDropBoxId": "drop3",
"routingHostIdList": [
"first-agent",
"second-agent",
"third-agent"
]
},
{
"postman-id": "postman3",
"task-type": "FILE_READ_THEN_SEND",
"postmanId": "postman3",
"taskType": "FILE_READ_THEN_SEND",
"action": {
"type": "SCHEDULED",
"cron": "0 1 3 * * *"
},
"message": {
"message-type": "TRANSFER_FILE",
"watch-directory": "D:\\projects\\bsm-lab\\dfx\\run\\send_file",
"meta-data-data-source-id": "save-work-image-file-info",
"meta-data-sql-id": "dfcms.file.selectFileInfo",
"meta-drop-box-id": "save-work-image-file-info"
"messageType": "TRANSFER_FILE",
"watchDirectory": "D:\\projects\\bsm-lab\\dfx\\run\\send_file",
"metaDataDataSourceId": "save-work-image-file-info",
"metaDataSqlId": "dfcms.file.selectFileInfo",
"metaDropBoxId": "save-work-image-file-info"
},
"recipient-host-id": "third-agent",
"recipient-drop-box-id": "drop4",
"routing-host-id-list": ["first-agent", "second-agent", "third-agent"]
"recipientHostId": "third-agent",
"recipientDropBoxId": "drop4",
"routingHostIdList": [
"first-agent",
"second-agent",
"third-agent"
]
}
]
}
}

@ -6,8 +6,8 @@ import java.util.List;
@Data
public class AgentConfigDto {
private String hostId;
private int listenPort;
private String myHostId;
private int myListenPort;
private List<KnownAgent> knownAgentList;
private List<DataSourceConfig> datasourceConfig;
private List<String> sqlMapperLocations;

@ -8,28 +8,15 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.annotation.MapperScan;
import org.mybatis.spring.annotation.MapperScans;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import javax.sql.DataSource;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -45,13 +32,10 @@ public class DfxAgentConfiguration {
private static final String DB_SOURCE_FILE_PATH = "./storages/dfxagent.mv.db";
// gradle bootRun 실행 설정
// bootRun --args="--embedded.db.file.directory=D:\projects\bsm-lab\dfx\dfxagent\src\docs\settings-examples --setting.file=D:\projects\bsm-lab\dfx\dfxagent\src\docs\settings-examples\dfxagent.json"
// bootRun --args=" --setting.file=D:\projects\bsm-lab\dfx\dfxagent\src\docs\settings-examples\dfxagent.json"
// command line java 실행 설정
// java -jar dfxagent.jar --embedded.db.file.directory=D:\projects\bsm-lab\dfx\dfxagent\src\docs\settings-examples --setting.file=D:\projects\bsm-lab\dfx\dfxagent\src\docs\settings-examples\dfxagent.json
// java -jar dfxagent.jar --setting.file=D:\projects\bsm-lab\dfx\dfxagent\src\docs\settings-examples\dfxagent.json
//example: embedded.db.file.directory=D:\projects\bsm-lab\dfx\dfxagent\src\docs\settings-examples
@Value("${embedded.db.file.directory}")
private String embeddedDbFileDirectory;
//example: setting.file=D:\projects\bsm-lab\dfx\dfxagent\src\docs\settings-examples\dfxagent.json
@Value("${setting.file}")
private String settingFile;
@ -62,11 +46,6 @@ public class DfxAgentConfiguration {
// agent 설정 관리자. 대부분의 기능에 필요함
@Bean(name = "agentConfigReader")
public AgentConfigReader agentConfigReader() {
if(StringUtils.isBlank(this.embeddedDbFileDirectory)) {
log.error("cannot found a embedded DB file. {}", this.embeddedDbFileDirectory);
log.error("exit application");
System.exit(0);
}
if(StringUtils.isBlank(this.settingFile)) {
log.error("cannot found a setting file. {}", this.settingFile);
log.error("exit application");
@ -146,58 +125,6 @@ public class DfxAgentConfiguration {
return dynamicDataSourceService;
}
// 연계 처리 결과 관리할 내부 DB 사용여부 결정 못함
public void copyEmbeddedDbFileIfNotExists() {
String embeddedDbFileDirectory = System.getProperty("embedded.db.file.directory");
File targetDirectory = new File(embeddedDbFileDirectory);
if(!targetDirectory.exists()) {
targetDirectory = new File(System.getProperty("user.home"));
}
File targetFile = new File(targetDirectory.getAbsoluteFile() + "/dfxagent.mv.db");
log.debug("embeddedDbFilePath: {}", embeddedDbFileDirectory);
if(!targetFile.exists()) {
try {
InputStream inputStream = new ClassPathResource(DB_SOURCE_FILE_PATH).getInputStream();
log.debug("embedded db file copy from {} to {}", DB_SOURCE_FILE_PATH, embeddedDbFileDirectory);
Files.copy(inputStream, Paths.get(targetFile.getAbsolutePath()), StandardCopyOption.REPLACE_EXISTING);
}
catch (IOException e) {
log.error("cannot make Embedded DB files. exit application.");
System.exit(0);
}
}
}
// 연계 처리 결과 관리할 내부 DB 사용여부 결정 못함
@Bean(name = "innerDataSource")
@ConfigurationProperties("spring.datasource") // application.yml 에서 설정된 값 자동 적용
public DataSource innerDataSource(DataSourceProperties dataSourceProperties) {
return dataSourceProperties.initializeDataSourceBuilder().build();
}
// 연계 처리 결과 관리할 내부 DB 사용여부 결정 못함
@Bean(name = "innerSqlSessionFactory")
public SqlSessionFactory innerSqlSessionFactory(@Qualifier("innerDataSource") DataSource dataSource) throws Exception {
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
sqlSessionFactoryBean.setDataSource(dataSource);
sqlSessionFactoryBean.setMapperLocations(
new PathMatchingResourcePatternResolver().getResources("classpath:mapper/**/*.xml")
);
return sqlSessionFactoryBean.getObject();
}
// 연계 처리 결과 관리할 내부 DB 사용여부 결정 못함
@Bean(name = "innerSqlSessionTemplate")
public SqlSessionTemplate innerSqlSessionTemplate(@Qualifier("innerSqlSessionFactory") SqlSessionFactory innerSqlSessionFactory) {
return new SqlSessionTemplate(innerSqlSessionFactory);
}
// 연계 처리 결과 관리할 내부 DB 사용여부 결정 못함
@Bean(name = "innerTransactionManager")
public DataSourceTransactionManager innerTransactionManager(@Qualifier("innerDataSource") DataSource dataSource) {
return new DataSourceTransactionManager(dataSource);
}
// (수신 처리) 메시지 수신 - 저장 후 수신 메시지 처리 쓰레드 설정
@Bean(name = "dropBoxProcessorThreadPoolTaskExecutor")
public Executor dropBoxProcessorThreadPoolTaskExecutor() {

@ -13,7 +13,7 @@ public class WebServerCustomizer implements WebServerFactoryCustomizer<Configura
private final AgentConfigReader agentConfigReader;
@Override
public void customize(ConfigurableServletWebServerFactory factory) {
int port = agentConfigReader.getAgentConfigDto().getListenPort();
int port = agentConfigReader.getAgentConfigDto().getMyListenPort();
factory.setPort(port);
factory.setContextPath("/");
}

@ -3,7 +3,6 @@ package com.bsmlab.dfx.agent.listener;
import com.bsmlab.dfx.agent.listener.dto.AckDto;
import com.bsmlab.dfx.agent.listener.service.ListenerService;
import com.bsmlab.dfx.agent.support.ServletUtils;
import com.bsmlab.dfx.agent.support.exception.IllegalMessageException;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.Part;
@ -14,7 +13,6 @@ import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;
@Slf4j
@RestController
@ -37,7 +35,7 @@ public class ListenerController {
ackDto = listenerService.receiveMessage(bodyString);
}
else if(contentType != null && contentType.contains("multipart/form-data")) {
//TODO 파일 전송인 경우 Multipart로 전송하며 파일의 메타데이터인 application/json 과 n개의 파일 본문인 File Multipart 를 합쳐서 전송한다.
//파일 전송인 경우 Multipart로 전송하며 파일의 메타데이터인 application/json 과 n개의 파일 본문인 File Multipart 를 합쳐서 전송한다.
Collection<Part> parts = request.getParts();
ackDto = listenerService.receiveFiles(parts);
}

@ -33,14 +33,14 @@ public class MessageUtils {
}
Map<String, Object> senderMap = (Map<String, Object>)map.get("sender");
String senderHostId;
if(senderMap.get("host-id") == null) {
throw new InCompleteMessageException("sender.host-id 엘리먼트를 찾을 수 없습니다.");
if(senderMap.get("hostId") == null) {
throw new InCompleteMessageException("sender.hostId 엘리먼트를 찾을 수 없습니다.");
}
else if(StringUtils.isBlank(String.valueOf(senderMap.get("host-id")))) {
throw new InCompleteMessageException("sender.host-id 값을 찾을 수 없습니다.");
else if(StringUtils.isBlank(String.valueOf(senderMap.get("hostId")))) {
throw new InCompleteMessageException("sender.hostId 값을 찾을 수 없습니다.");
}
else {
senderHostId = String.valueOf(senderMap.get("host-id"));
senderHostId = String.valueOf(senderMap.get("hostId"));
}
long senderTimestamp = 0;
if(senderMap.get("timestamp") == null) {
@ -58,19 +58,19 @@ public class MessageUtils {
}
}
String messageUuid;
if(map.get("message-uuid") == null) {
throw new InCompleteMessageException("message-uuid 엘리먼트를 찾을 수 없습니다.");
if(map.get("messageUuid") == null) {
throw new InCompleteMessageException("messageUuid 엘리먼트를 찾을 수 없습니다.");
}
else if(StringUtils.isBlank(String.valueOf(map.get("message-uuid")))) {
throw new InCompleteMessageException("message-uuid 값을 찾을 수 없습니다.");
else if(StringUtils.isBlank(String.valueOf(map.get("messageUuid")))) {
throw new InCompleteMessageException("messageUuid 값을 찾을 수 없습니다.");
}
else {
messageUuid = String.valueOf(map.get("message-uuid"));
messageUuid = String.valueOf(map.get("messageUuid"));
try {
UUID.fromString(messageUuid);
}
catch (IllegalArgumentException e) {
throw new InCompleteMessageException("message-uuid 값의 형식이 숫자형식이 아닙니다. " + messageUuid);
throw new InCompleteMessageException("messageUuid 값의 형식이 숫자형식이 아닙니다. " + messageUuid);
}
}
long receivedTimestamp = System.currentTimeMillis();
@ -83,36 +83,36 @@ public class MessageUtils {
Map<String, Object> recipientMap = (Map<String, Object>)map.get("recipient");
//TODO recipient
String recipientHostId;
if(recipientMap.get("host-id") == null) {
throw new InCompleteMessageException("recipient.host-id 엘리먼트를 찾을 수 없습니다.");
if(recipientMap.get("hostId") == null) {
throw new InCompleteMessageException("recipient.hostId 엘리먼트를 찾을 수 없습니다.");
}
else if(StringUtils.isBlank(String.valueOf(recipientMap.get("host-id")))) {
throw new InCompleteMessageException("recipient.host-id 값을 찾을 수 없습니다.");
else if(StringUtils.isBlank(String.valueOf(recipientMap.get("hostId")))) {
throw new InCompleteMessageException("recipient.hostId 값을 찾을 수 없습니다.");
}
else {
recipientHostId = String.valueOf(recipientMap.get("host-id"));
recipientHostId = String.valueOf(recipientMap.get("hostId"));
}
String recipientDropBoxId;
if(recipientMap.get("drop-box-id") == null) {
throw new InCompleteMessageException("recipient.drop-box-id 엘리먼트를 찾을 수 없습니다.");
if(recipientMap.get("dropBoxId") == null) {
throw new InCompleteMessageException("recipient.dropBoxId 엘리먼트를 찾을 수 없습니다.");
}
else if(StringUtils.isBlank(String.valueOf(recipientMap.get("drop-box-id")))) {
throw new InCompleteMessageException("recipient.drop-box-id 값을 찾을 수 없습니다.");
else if(StringUtils.isBlank(String.valueOf(recipientMap.get("dropBoxId")))) {
throw new InCompleteMessageException("recipient.dropBoxId 값을 찾을 수 없습니다.");
}
else {
recipientDropBoxId = String.valueOf(recipientMap.get("drop-box-id"));
recipientDropBoxId = String.valueOf(recipientMap.get("dropBoxId"));
}
AgentConfigDto.MessageType messageType;
if(map.get("message-type") == null) {
throw new InCompleteMessageException("message-type 엘리먼트를 찾을 수 없습니다.");
if(map.get("messageType") == null) {
throw new InCompleteMessageException("messageType 엘리먼트를 찾을 수 없습니다.");
}
else if(StringUtils.isBlank(String.valueOf(map.get("message-type")))) {
throw new InCompleteMessageException("message-type 값을 찾을 수 없습니다.");
else if(StringUtils.isBlank(String.valueOf(map.get("messageType")))) {
throw new InCompleteMessageException("messageType 값을 찾을 수 없습니다.");
}
else {
String messageTypeString = String.valueOf(map.get("message-type"));
String messageTypeString = String.valueOf(map.get("messageType"));
if(!EnumUtils.isValidEnum(AgentConfigDto.MessageType.class, messageTypeString)) {
throw new InCompleteMessageException("message-type 값이 옳바르지 않습니다. " + messageTypeString);
throw new InCompleteMessageException("messageType 값이 옳바르지 않습니다. " + messageTypeString);
}
messageType = EnumUtils.getEnum(AgentConfigDto.MessageType.class, messageTypeString);
}

@ -26,7 +26,6 @@ import org.springframework.web.client.RestTemplate;
import java.io.File;
import java.io.IOException;
import java.nio.file.CopyOption;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.text.SimpleDateFormat;
@ -69,7 +68,7 @@ public class PostmanSchedulerService {
public void run(AgentConfigDto.Postman postman) {
ObjectMapper objectMapper = new ObjectMapper();
String senderHostId = agentConfigReader.getAgentConfigDto().getHostId();
String senderHostId = agentConfigReader.getAgentConfigDto().getMyHostId();
long senderTimestamp = System.currentTimeMillis();
String messageUuid = UUID.randomUUID().toString();
// DB TO DB 전송
@ -188,13 +187,6 @@ public class PostmanSchedulerService {
throw new RuntimeException(e);
}
}
// Path startPath = Paths.get("C:/example"); // 시작 디렉토리 경로
//
// try (Stream<Path> stream = Files.walk(startPath)) {
// stream.filter(Files::isRegularFile)
// .forEach(System.out::println);
// }
}
}
}

@ -1,18 +1,6 @@
spring:
application:
name: DFX Agent
h2:
console:
enabled: true
path: /dfxagent-db-console
settings:
web-allow-others: true
datasource:
driverClassName: org.h2.Driver
#url: jdbc:h2:classpath:/storages/dfxagent
url: jdbc:h2:~/dfxagent
username: smbaek
password: qortpals1!
logging:
level:
com.bsmlab.dfx.agent: DEBUG

Loading…
Cancel
Save